Commit 81801ccc authored by atsushi-ishibashi's avatar atsushi-ishibashi Committed by Martin Holst Swende

core/state: more memory efficient preimage allocation (#16663)

parent c57166ca
......@@ -502,7 +502,7 @@ func (self *StateDB) Copy() *StateDB {
refund: self.refund,
logs: make(map[common.Hash][]*types.Log, len(self.logs)),
logSize: self.logSize,
preimages: make(map[common.Hash][]byte),
preimages: make(map[common.Hash][]byte, len(self.preimages)),
journal: newJournal(),
}
// Copy the dirty states, logs, and preimages
......
......@@ -276,6 +276,15 @@ func newTestAction(addr common.Address, r *rand.Rand) testAction {
},
args: make([]int64, 1),
},
{
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))]
var nameargs []string
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment