mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
trie: fix tiny issue
This commit is contained in:
parent
140be4e19e
commit
90b0f452e9
2 changed files with 4 additions and 8 deletions
|
|
@ -81,12 +81,6 @@ func (n *extNodeEncoder) encode(w rlp.EncoderBuffer) {
|
|||
|
||||
func (n *leafNodeEncoder) encode(w rlp.EncoderBuffer) {
|
||||
offset := w.List()
|
||||
|
||||
// Encode the key to Compact format. The assumption is held
|
||||
// that it's safe to modify the key in place.
|
||||
n.Key = append(n.Key, 16) // termination flag
|
||||
n.Key = hexToCompactInPlace(n.Key)
|
||||
|
||||
w.WriteBytes(n.Key) // Compact format key
|
||||
w.WriteBytes(n.Val) // Value node, must be non-nil
|
||||
w.ListEnd(offset)
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ func (t *StackTrie) grow(key []byte) {
|
|||
if cap(t.kBuf) < 2*len(key) {
|
||||
t.kBuf = make([]byte, 2*len(key))
|
||||
}
|
||||
if cap(t.pBuf) < len(key) {
|
||||
if cap(t.pBuf) < 2*len(key) {
|
||||
t.pBuf = make([]byte, 2*len(key))
|
||||
}
|
||||
}
|
||||
|
|
@ -353,6 +353,7 @@ func (t *StackTrie) hash(st *stNode, path []byte) {
|
|||
}
|
||||
nodes.encode(t.h.encbuf)
|
||||
blob = t.h.encodedBytes()
|
||||
|
||||
for i, child := range st.children {
|
||||
if child == nil {
|
||||
continue
|
||||
|
|
@ -377,8 +378,9 @@ func (t *StackTrie) hash(st *stNode, path []byte) {
|
|||
st.children[0] = nil
|
||||
|
||||
case leafNode:
|
||||
st.key = append(st.key, byte(16))
|
||||
n := leafNodeEncoder{
|
||||
Key: st.key,
|
||||
Key: hexToCompactInPlace(st.key),
|
||||
Val: st.val,
|
||||
}
|
||||
n.encode(t.h.encbuf)
|
||||
|
|
|
|||
Loading…
Reference in a new issue