diff --git a/lib/trie/hash.go b/lib/trie/hash.go index f798f594b8..887ed83731 100644 --- a/lib/trie/hash.go +++ b/lib/trie/hash.go @@ -98,6 +98,8 @@ func encodeNode(n node, buffer *bytes.Buffer, parallel bool) (err error) { n.encodingMu.Lock() defer n.encodingMu.Unlock() + // TODO remove this copying since it defeats the purpose of `buffer` + // and the sync.Pool. n.encoding = make([]byte, buffer.Len()) copy(n.encoding, buffer.Bytes()) return nil diff --git a/lib/trie/node.go b/lib/trie/node.go index b7ae35d9db..cc55da89c3 100644 --- a/lib/trie/node.go +++ b/lib/trie/node.go @@ -277,6 +277,8 @@ func (l *leaf) encodeAndHash() (encoding, hash []byte, err error) { bufferBytes := buffer.Bytes() l.encodingMu.Lock() + // TODO remove this copying since it defeats the purpose of `buffer` + // and the sync.Pool. l.encoding = make([]byte, len(bufferBytes)) copy(l.encoding, bufferBytes) l.encodingMu.Unlock()