@@ -22,8 +22,6 @@ import (
2222 "sync"
2323
2424 "github.com/XinFinOrg/XDPoSChain/common"
25- "github.com/XinFinOrg/XDPoSChain/crypto"
26- "golang.org/x/crypto/sha3"
2725)
2826
2927// leafChanSize is the size of the leafCh. It's a pretty arbitrary number, to allow
@@ -44,18 +42,14 @@ type leaf struct {
4442// By 'some level' of parallelism, it's still the case that all leaves will be
4543// processed sequentially - onleaf will never be called in parallel or out of order.
4644type committer struct {
47- sha crypto.KeccakState
48-
4945 onleaf LeafCallback
5046 leafCh chan * leaf
5147}
5248
5349// committers live in a global sync.Pool
5450var committerPool = sync.Pool {
5551 New : func () interface {} {
56- return & committer {
57- sha : sha3 .NewLegacyKeccak256 ().(crypto.KeccakState ),
58- }
52+ return & committer {}
5953 },
6054}
6155
@@ -231,15 +225,7 @@ func (c *committer) commitLoop(db *Database) {
231225 }
232226}
233227
234- func (c * committer ) makeHashNode (data []byte ) hashNode {
235- n := make (hashNode , c .sha .Size ())
236- c .sha .Reset ()
237- c .sha .Write (data )
238- c .sha .Read (n )
239- return n
240- }
241-
242- // estimateSize estimates the size of an rlp-encoded Node, without actually
228+ // estimateSize estimates the size of an rlp-encoded node, without actually
243229// rlp-encoding it (zero allocs). This method has been experimentally tried, and with a trie
244230// with 1000 leafs, the only errors above 1% are on small shortnodes, where this
245231// method overestimates by 2 or 3 bytes (e.g. 37 instead of 35)
0 commit comments