From e4de0e82a2b68f6df97e96e3647be2a05656bd4e Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Tue, 17 Jun 2025 13:28:59 +0800 Subject: [PATCH] trie: remove unused makeHashNode #24702 (#1089) Co-authored-by: Darioush Jalali --- trie/committer.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/trie/committer.go b/trie/committer.go index f89ac6d71d..f5980cf00e 100644 --- a/trie/committer.go +++ b/trie/committer.go @@ -22,8 +22,6 @@ import ( "sync" "github.com/XinFinOrg/XDPoSChain/common" - "github.com/XinFinOrg/XDPoSChain/crypto" - "golang.org/x/crypto/sha3" ) // leafChanSize is the size of the leafCh. It's a pretty arbitrary number, to allow @@ -44,8 +42,6 @@ type leaf struct { // By 'some level' of parallelism, it's still the case that all leaves will be // processed sequentially - onleaf will never be called in parallel or out of order. type committer struct { - sha crypto.KeccakState - onleaf LeafCallback leafCh chan *leaf } @@ -53,9 +49,7 @@ type committer struct { // committers live in a global sync.Pool var committerPool = sync.Pool{ New: func() interface{} { - return &committer{ - sha: sha3.NewLegacyKeccak256().(crypto.KeccakState), - } + return &committer{} }, } @@ -231,15 +225,7 @@ func (c *committer) commitLoop(db *Database) { } } -func (c *committer) makeHashNode(data []byte) hashNode { - n := make(hashNode, c.sha.Size()) - c.sha.Reset() - c.sha.Write(data) - c.sha.Read(n) - return n -} - -// estimateSize estimates the size of an rlp-encoded Node, without actually +// estimateSize estimates the size of an rlp-encoded node, without actually // rlp-encoding it (zero allocs). This method has been experimentally tried, and with a trie // with 1000 leafs, the only errors above 1% are on small shortnodes, where this // method overestimates by 2 or 3 bytes (e.g. 37 instead of 35)