diff options
author | Martin Holst Swende <martin@swende.se> | 2018-04-11 02:59:07 +0800 |
---|---|---|
committer | Martin Holst Swende <martin@swende.se> | 2018-04-11 16:23:01 +0800 |
commit | 0c7b99b8cc754a0045518ac12b8d1719c23b4181 (patch) | |
tree | 0a766a13459f4c8e3a0071c430be1aa373f33407 /core/state/statedb.go | |
parent | 2e247705cd27e919e806f29ff2adcd57c163b1ac (diff) | |
download | dexon-0c7b99b8cc754a0045518ac12b8d1719c23b4181.tar dexon-0c7b99b8cc754a0045518ac12b8d1719c23b4181.tar.gz dexon-0c7b99b8cc754a0045518ac12b8d1719c23b4181.tar.bz2 dexon-0c7b99b8cc754a0045518ac12b8d1719c23b4181.tar.lz dexon-0c7b99b8cc754a0045518ac12b8d1719c23b4181.tar.xz dexon-0c7b99b8cc754a0045518ac12b8d1719c23b4181.tar.zst dexon-0c7b99b8cc754a0045518ac12b8d1719c23b4181.zip |
core/state: fix bug in copy of copy State
Diffstat (limited to 'core/state/statedb.go')
-rw-r--r-- | core/state/statedb.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/core/state/statedb.go b/core/state/statedb.go index 08f18c2d2..97c6e4a01 100644 --- a/core/state/statedb.go +++ b/core/state/statedb.go @@ -474,6 +474,16 @@ func (self *StateDB) Copy() *StateDB { state.stateObjects[addr] = self.stateObjects[addr].deepCopy(state) state.stateObjectsDirty[addr] = struct{}{} } + // Above, we don't copy the actual journal. This means that if the copy is copied, the + // loop above will be a no-op, since the copy's journal is empty. + // Thus, here we iterate over stateObjects, to enable copies of copies + for addr := range self.stateObjectsDirty { + if _, exist := state.stateObjects[addr]; !exist { + state.stateObjects[addr] = self.stateObjects[addr].deepCopy(state) + state.stateObjectsDirty[addr] = struct{}{} + } + } + for hash, logs := range self.logs { state.logs[hash] = make([]*types.Log, len(logs)) copy(state.logs[hash], logs) |