From 1d42888d3047dabfb352c94a2051e7af14d2a509 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 16 Jun 2015 12:41:50 +0200 Subject: core/types: make blocks immutable --- core/state_transition.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'core/state_transition.go') diff --git a/core/state_transition.go b/core/state_transition.go index 915dd466b..2c8770cbe 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -73,16 +73,17 @@ func MessageGasValue(msg Message) *big.Int { return new(big.Int).Mul(msg.Gas(), msg.GasPrice()) } -func IntrinsicGas(msg Message) *big.Int { +// IntrinsicGas computes the 'intrisic gas' for a message +// with the given data. +func IntrinsicGas(data []byte) *big.Int { igas := new(big.Int).Set(params.TxGas) - for _, byt := range msg.Data() { + for _, byt := range data { if byt != 0 { igas.Add(igas, params.TxDataNonZeroGas) } else { igas.Add(igas, params.TxDataZeroGas) } } - return igas } @@ -195,7 +196,7 @@ func (self *StateTransition) transitionState() (ret []byte, usedGas *big.Int, er sender, _ := self.From() // err checked in preCheck // Pay intrinsic gas - if err = self.UseGas(IntrinsicGas(self.msg)); err != nil { + if err = self.UseGas(IntrinsicGas(self.msg.Data())); err != nil { return nil, nil, InvalidTxError(err) } -- cgit v1.2.3