mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-18 19:00:46 +00:00
parent
b4f4b95634
commit
9affb6a582
2 changed files with 11 additions and 4 deletions
|
|
@ -19,6 +19,7 @@ package state
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"maps"
|
||||||
"math/big"
|
"math/big"
|
||||||
"sort"
|
"sort"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -637,7 +638,7 @@ func (s *StateDB) Copy() *StateDB {
|
||||||
refund: s.refund,
|
refund: s.refund,
|
||||||
logs: make(map[common.Hash][]*types.Log, len(s.logs)),
|
logs: make(map[common.Hash][]*types.Log, len(s.logs)),
|
||||||
logSize: s.logSize,
|
logSize: s.logSize,
|
||||||
preimages: make(map[common.Hash][]byte),
|
preimages: maps.Clone(s.preimages),
|
||||||
journal: newJournal(),
|
journal: newJournal(),
|
||||||
}
|
}
|
||||||
// Copy the dirty states, logs, and preimages
|
// Copy the dirty states, logs, and preimages
|
||||||
|
|
@ -683,9 +684,6 @@ func (s *StateDB) Copy() *StateDB {
|
||||||
state.logs[hash] = cpy
|
state.logs[hash] = cpy
|
||||||
}
|
}
|
||||||
|
|
||||||
for hash, preimage := range s.preimages {
|
|
||||||
state.preimages[hash] = preimage
|
|
||||||
}
|
|
||||||
// Do we need to copy the access list? In practice: No. At the start of a
|
// Do we need to copy the access list? In practice: No. At the start of a
|
||||||
// transaction, the access list is empty. In practice, we only ever copy state
|
// transaction, the access list is empty. In practice, we only ever copy state
|
||||||
// _between_ transactions/blocks, never in the middle of a transaction.
|
// _between_ transactions/blocks, never in the middle of a transaction.
|
||||||
|
|
|
||||||
|
|
@ -305,6 +305,15 @@ func newTestAction(addr common.Address, r *rand.Rand) testAction {
|
||||||
},
|
},
|
||||||
args: make([]int64, 2),
|
args: make([]int64, 2),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "AddPreimage",
|
||||||
|
fn: func(a testAction, s *StateDB) {
|
||||||
|
preimage := []byte{1}
|
||||||
|
hash := common.BytesToHash(preimage)
|
||||||
|
s.AddPreimage(hash, preimage)
|
||||||
|
},
|
||||||
|
args: make([]int64, 1),
|
||||||
|
},
|
||||||
}
|
}
|
||||||
action := actions[r.Intn(len(actions))]
|
action := actions[r.Intn(len(actions))]
|
||||||
var nameargs []string
|
var nameargs []string
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue