Skip to content

Commit e4de0e8

Browse files
gzliudanDarioush Jalali
andauthored
trie: remove unused makeHashNode ethereum#24702 (#1089)
Co-authored-by: Darioush Jalali <darioush.jalali@avalabs.org>
1 parent 205a94e commit e4de0e8

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

trie/committer.go

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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.
4644
type committer struct {
47-
sha crypto.KeccakState
48-
4945
onleaf LeafCallback
5046
leafCh chan *leaf
5147
}
5248

5349
// committers live in a global sync.Pool
5450
var 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

Comments
 (0)