From 37494126046bf265ec066ac4e5b619a4a8312fc9 Mon Sep 17 00:00:00 2001 From: Roy Crihfield Date: Thu, 3 Aug 2023 18:33:51 +0800 Subject: [PATCH] reorder funcs, and add comment --- trie/iterator.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/trie/iterator.go b/trie/iterator.go index 5338aed8e7..ae4a1956f4 100644 --- a/trie/iterator.go +++ b/trie/iterator.go @@ -563,6 +563,9 @@ func reachedPath(path, target []byte) bool { return bytes.Compare(path, target) >= 0 } +// A value embedded in a fullNode occupies its last child slot, but we want to visit it last to +// produce a pre-order traversal. These two functions handle the ordering by mapping index 0 to the +// value, and shifting the indices of children over by 1. func prevChildIndex(index int) int { switch index { case 0: