diff options
Diffstat (limited to 'chain/state_transition.go')
-rw-r--r-- | chain/state_transition.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/chain/state_transition.go b/chain/state_transition.go index 789698675..53b1f6e2d 100644 --- a/chain/state_transition.go +++ b/chain/state_transition.go @@ -157,12 +157,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) } |