aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authoratsushi-ishibashi <atsushi.ishibashi@finatext.com>2019-02-07 17:44:45 +0800
committerMartin Holst Swende <martin@swende.se>2019-02-07 17:44:45 +0800
commit81801ccc2b5444ebcf05bf1cf1562fc7a7c2b93e (patch)
tree8831b01cb8b5e9d05413195e9748c4cce918d9ff /core
parentc57166caa371d5b67db39f6f6851856023f8423c (diff)
downloadgo-tangerine-81801ccc2b5444ebcf05bf1cf1562fc7a7c2b93e.tar
go-tangerine-81801ccc2b5444ebcf05bf1cf1562fc7a7c2b93e.tar.gz
go-tangerine-81801ccc2b5444ebcf05bf1cf1562fc7a7c2b93e.tar.bz2
go-tangerine-81801ccc2b5444ebcf05bf1cf1562fc7a7c2b93e.tar.lz
go-tangerine-81801ccc2b5444ebcf05bf1cf1562fc7a7c2b93e.tar.xz
go-tangerine-81801ccc2b5444ebcf05bf1cf1562fc7a7c2b93e.tar.zst
go-tangerine-81801ccc2b5444ebcf05bf1cf1562fc7a7c2b93e.zip
core/state: more memory efficient preimage allocation (#16663)
Diffstat (limited to 'core')
-rw-r--r--core/state/statedb.go2
-rw-r--r--core/state/statedb_test.go9
2 files changed, 10 insertions, 1 deletions
diff --git a/core/state/statedb.go b/core/state/statedb.go
index 2230b10ef..8ad25a582 100644
--- a/core/state/statedb.go
+++ b/core/state/statedb.go
@@ -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
diff --git a/core/state/statedb_test.go b/core/state/statedb_test.go
index cbd5bc75e..69392d972 100644
--- a/core/state/statedb_test.go
+++ b/core/state/statedb_test.go
@@ -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