Skip to content
This repository has been archived by the owner on Oct 4, 2019. It is now read-only.

Commit

Permalink
problem: concurrent rw on state db stateobjects map
Browse files Browse the repository at this point in the history
solution: use mutex lock

fixes #284, again
  • Loading branch information
whilei committed Jun 2, 2018
1 parent a9c8b13 commit b059469
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,12 +349,15 @@ func (self *StateDB) deleteStateObject(stateObject *StateObject) {
// Retrieve a state object given my the address. Returns nil if not found.
func (self *StateDB) getStateObject(addr common.Address) (stateObject *StateObject) {
// Prefer 'live' objects.
self.lock.Lock()
if obj := self.stateObjects[addr]; obj != nil {
self.lock.Unlock()
if obj.deleted {
return nil
}
return obj
}
self.lock.Unlock()

// Load the object from the database.
enc, err := self.trie.TryGet(addr[:])
Expand Down

0 comments on commit b059469

Please sign in to comment.