|
|
@ -109,7 +109,7 @@ func NewStateObjectFromBytes(address common.Address, data []byte, db common.Data |
|
|
|
object.nonce = extobject.Nonce |
|
|
|
object.nonce = extobject.Nonce |
|
|
|
object.balance = extobject.Balance |
|
|
|
object.balance = extobject.Balance |
|
|
|
object.codeHash = extobject.CodeHash |
|
|
|
object.codeHash = extobject.CodeHash |
|
|
|
object.State = New(extobject.Root, db) |
|
|
|
object.State = New(extobject.Root[:], db) |
|
|
|
object.storage = make(map[string]*common.Value) |
|
|
|
object.storage = make(map[string]*common.Value) |
|
|
|
object.gasPool = new(big.Int) |
|
|
|
object.gasPool = new(big.Int) |
|
|
|
object.prepaid = new(big.Int) |
|
|
|
object.prepaid = new(big.Int) |
|
|
@ -124,8 +124,8 @@ func (self *StateObject) MarkForDeletion() { |
|
|
|
statelogger.Debugf("%x: #%d %v X\n", self.Address(), self.nonce, self.balance) |
|
|
|
statelogger.Debugf("%x: #%d %v X\n", self.Address(), self.nonce, self.balance) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *StateObject) getAddr(addr []byte) *common.Value { |
|
|
|
func (c *StateObject) getAddr(addr common.Hash) *common.Value { |
|
|
|
return common.NewValueFromBytes([]byte(c.State.trie.Get(addr))) |
|
|
|
return common.NewValueFromBytes([]byte(c.State.trie.Get(addr[:]))) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (c *StateObject) setAddr(addr []byte, value interface{}) { |
|
|
|
func (c *StateObject) setAddr(addr []byte, value interface{}) { |
|
|
@ -133,34 +133,32 @@ func (c *StateObject) setAddr(addr []byte, value interface{}) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self *StateObject) GetStorage(key *big.Int) *common.Value { |
|
|
|
func (self *StateObject) GetStorage(key *big.Int) *common.Value { |
|
|
|
return self.GetState(key.Bytes()) |
|
|
|
return self.GetState(common.BytesToHash(key.Bytes())) |
|
|
|
} |
|
|
|
} |
|
|
|
func (self *StateObject) SetStorage(key *big.Int, value *common.Value) { |
|
|
|
func (self *StateObject) SetStorage(key *big.Int, value *common.Value) { |
|
|
|
self.SetState(key.Bytes(), value) |
|
|
|
self.SetState(common.BytesToHash(key.Bytes()), value) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self *StateObject) Storage() Storage { |
|
|
|
func (self *StateObject) Storage() Storage { |
|
|
|
return self.storage |
|
|
|
return self.storage |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self *StateObject) GetState(k []byte) *common.Value { |
|
|
|
func (self *StateObject) GetState(key common.Hash) *common.Value { |
|
|
|
key := common.LeftPadBytes(k, 32) |
|
|
|
strkey := key.Str() |
|
|
|
|
|
|
|
value := self.storage[strkey] |
|
|
|
value := self.storage[string(key)] |
|
|
|
|
|
|
|
if value == nil { |
|
|
|
if value == nil { |
|
|
|
value = self.getAddr(key) |
|
|
|
value = self.getAddr(key) |
|
|
|
|
|
|
|
|
|
|
|
if !value.IsNil() { |
|
|
|
if !value.IsNil() { |
|
|
|
self.storage[string(key)] = value |
|
|
|
self.storage[strkey] = value |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return value |
|
|
|
return value |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (self *StateObject) SetState(k []byte, value *common.Value) { |
|
|
|
func (self *StateObject) SetState(k common.Hash, value *common.Value) { |
|
|
|
key := common.LeftPadBytes(k, 32) |
|
|
|
self.storage[k.Str()] = value.Copy() |
|
|
|
self.storage[string(key)] = value.Copy() |
|
|
|
|
|
|
|
self.dirty = true |
|
|
|
self.dirty = true |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|