aboutsummaryrefslogtreecommitdiffstats
path: root/core/state_transition.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2015-06-16 18:41:50 +0800
committerJeffrey Wilcke <geffobscura@gmail.com>2015-06-30 00:51:47 +0800
commit1d42888d3047dabfb352c94a2051e7af14d2a509 (patch)
tree8ca68ca98bd697f26f2033a5480e78ccbf064162 /core/state_transition.go
parent654564e164b3b6f7f4ba1e8bbd6fcd64776068fa (diff)
downloaddexon-1d42888d3047dabfb352c94a2051e7af14d2a509.tar.gz
dexon-1d42888d3047dabfb352c94a2051e7af14d2a509.tar.zst
dexon-1d42888d3047dabfb352c94a2051e7af14d2a509.zip
core/types: make blocks immutable
Diffstat (limited to 'core/state_transition.go')
-rw-r--r--core/state_transition.go9
1 files changed, 5 insertions, 4 deletions
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)
}