From 61556ef01de20a23951690376662ca58b345eca4 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 28 Nov 2014 20:47:24 +0100 Subject: GasData changes & removed min gas price --- chain/state_transition.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'chain/state_transition.go') diff --git a/chain/state_transition.go b/chain/state_transition.go index afe044299..f9b82c58b 100644 --- a/chain/state_transition.go +++ b/chain/state_transition.go @@ -156,12 +156,24 @@ func (self *StateTransition) TransitionState() (err error) { } // Pay data gas - dataPrice := big.NewInt(int64(len(self.data))) - dataPrice.Mul(dataPrice, vm.GasData) - if err = self.UseGas(dataPrice); err != nil { + var dgas int64 + for _, byt := range self.data { + if byt != 0 { + dgas += vm.GasData.Int64() + } else { + dgas += 1 // This is 1/5. If GasData changes this fails + } + } + if err = self.UseGas(big.NewInt(dgas)); err != nil { return } + //dataPrice := big.NewInt(int64(len(self.data))) + //dataPrice.Mul(dataPrice, vm.GasData) + //if err = self.UseGas(dataPrice); err != nil { + // return + //} + if sender.Balance().Cmp(self.value) < 0 { return fmt.Errorf("Insufficient funds to transfer value. Req %v, has %v", self.value, sender.Balance) } -- cgit v1.2.3