Procházet zdrojové kódy

core/statedb: deep copy logs (#17489)

gary rong před 7 roky
rodič
revize
c3f7e3be3b
1 změnil soubory, kde provedl 6 přidání a 3 odebrání
  1. 6 3
      core/state/statedb.go

+ 6 - 3
core/state/statedb.go

@@ -489,10 +489,13 @@ func (self *StateDB) Copy() *StateDB {
 			state.stateObjectsDirty[addr] = struct{}{}
 		}
 	}
-
 	for hash, logs := range self.logs {
-		state.logs[hash] = make([]*types.Log, len(logs))
-		copy(state.logs[hash], logs)
+		cpy := make([]*types.Log, len(logs))
+		for i, l := range logs {
+			cpy[i] = new(types.Log)
+			*cpy[i] = *l
+		}
+		state.logs[hash] = cpy
 	}
 	for hash, preimage := range self.preimages {
 		state.preimages[hash] = preimage