Use the state instead of the state object directly.
If a state gets reset and you still hold a pointer to the previous, incorrect, state object you'll operate on the wrong object. Using the state to set/get objects and attributes you won't have this problem since the state will always have the correct object.
This commit is contained in:
@@ -48,6 +48,13 @@ func (self *State) GetNonce(addr []byte) uint64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (self *State) SetNonce(addr []byte, nonce uint64) {
|
||||
stateObject := self.GetStateObject(addr)
|
||||
if stateObject != nil {
|
||||
stateObject.Nonce = nonce
|
||||
}
|
||||
}
|
||||
|
||||
func (self *State) GetCode(addr []byte) []byte {
|
||||
stateObject := self.GetStateObject(addr)
|
||||
if stateObject != nil {
|
||||
@@ -66,6 +73,24 @@ func (self *State) GetState(a, b []byte) []byte {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *State) SetState(addr, key []byte, value interface{}) {
|
||||
stateObject := self.GetStateObject(addr)
|
||||
if stateObject != nil {
|
||||
stateObject.SetState(key, ethutil.NewValue(value))
|
||||
}
|
||||
}
|
||||
|
||||
func (self *State) Delete(addr []byte) bool {
|
||||
stateObject := self.GetStateObject(addr)
|
||||
if stateObject != nil {
|
||||
stateObject.MarkForDeletion()
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
//
|
||||
// Setting, updating & deleting state object methods
|
||||
//
|
||||
|
Reference in New Issue
Block a user