mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 18:30:45 +00:00
add log deepcopy to ensure complete replica of state (#449)
implement "deep copy" as go-ethereum
This commit is contained in:
parent
77390d30ce
commit
06b280aa0d
1 changed files with 11 additions and 4 deletions
|
|
@ -544,10 +544,17 @@ func (self *StateDB) Copy() *StateDB {
|
||||||
state.stateObjects[addr] = self.stateObjects[addr].deepCopy(state, state.MarkStateObjectDirty)
|
state.stateObjects[addr] = self.stateObjects[addr].deepCopy(state, state.MarkStateObjectDirty)
|
||||||
state.stateObjectsDirty[addr] = struct{}{}
|
state.stateObjectsDirty[addr] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deep copy the logs occurred in the scope of block
|
||||||
for hash, logs := range self.logs {
|
for hash, logs := range self.logs {
|
||||||
state.logs[hash] = make([]*types.Log, len(logs))
|
cpy := make([]*types.Log, len(logs))
|
||||||
copy(state.logs[hash], logs)
|
for i, l := range logs {
|
||||||
|
cpy[i] = new(types.Log)
|
||||||
|
*cpy[i] = *l
|
||||||
}
|
}
|
||||||
|
state.logs[hash] = cpy
|
||||||
|
}
|
||||||
|
|
||||||
for hash, preimage := range self.preimages {
|
for hash, preimage := range self.preimages {
|
||||||
state.preimages[hash] = preimage
|
state.preimages[hash] = preimage
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue