aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-06-17 17:24:40 +0800
committerobscuren <geffobscura@gmail.com>2015-06-17 17:24:40 +0800
commit787a61bb27b9f51f4af67c69eb8f1c5869ae3144 (patch)
tree33405ad345b4350940eb163339c5a5de711bfc6e /core/vm
parent5721fcf668f8ab798b6602dc6ff88726bf0c8f86 (diff)
downloaddexon-787a61bb27b9f51f4af67c69eb8f1c5869ae3144.tar
dexon-787a61bb27b9f51f4af67c69eb8f1c5869ae3144.tar.gz
dexon-787a61bb27b9f51f4af67c69eb8f1c5869ae3144.tar.bz2
dexon-787a61bb27b9f51f4af67c69eb8f1c5869ae3144.tar.lz
dexon-787a61bb27b9f51f4af67c69eb8f1c5869ae3144.tar.xz
dexon-787a61bb27b9f51f4af67c69eb8f1c5869ae3144.tar.zst
dexon-787a61bb27b9f51f4af67c69eb8f1c5869ae3144.zip
core/state, core/vm: reworked storage get / set to use common.Hash
Diffstat (limited to 'core/vm')
-rw-r--r--core/vm/vm.go15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/vm/vm.go b/core/vm/vm.go
index 0486fbbc7..336f6cf95 100644
--- a/core/vm/vm.go
+++ b/core/vm/vm.go
@@ -506,14 +506,14 @@ func (self *Vm) Run(context *Context, input []byte) (ret []byte, err error) {
case SLOAD:
loc := common.BigToHash(stack.pop())
- val := common.Bytes2Big(statedb.GetState(context.Address(), loc))
+ val := statedb.GetState(context.Address(), loc).Big()
stack.push(val)
case SSTORE:
loc := common.BigToHash(stack.pop())
val := stack.pop()
- statedb.SetState(context.Address(), loc, val)
+ statedb.SetState(context.Address(), loc, common.BigToHash(val))
case JUMP:
if err := jump(pc, stack.pop()); err != nil {
@@ -686,10 +686,10 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
var g *big.Int
y, x := stack.data[stack.len()-2], stack.data[stack.len()-1]
val := statedb.GetState(context.Address(), common.BigToHash(x))
- if len(val) == 0 && len(y.Bytes()) > 0 {
+ if common.EmptyHash(val) && !common.EmptyHash(common.BigToHash(y)) {
// 0 => non 0
g = params.SstoreSetGas
- } else if len(val) > 0 && len(y.Bytes()) == 0 {
+ } else if !common.EmptyHash(val) && common.EmptyHash(common.BigToHash(y)) {
statedb.Refund(params.SstoreRefundGas)
g = params.SstoreClearGas
@@ -697,6 +697,13 @@ func (self *Vm) calculateGasAndSize(context *Context, caller ContextRef, op OpCo
// non 0 => non 0 (or 0 => 0)
g = params.SstoreClearGas
}
+
+ /*
+ if len(val) == 0 && len(y.Bytes()) > 0 {
+ } else if len(val) > 0 && len(y.Bytes()) == 0 {
+ } else {
+ }
+ */
gas.Set(g)
case SUICIDE:
if !statedb.IsDeleted(context.Address()) {