From e6f16834232728110aa38ea3e343140edf5e28b8 Mon Sep 17 00:00:00 2001 From: Matt Kocubinski Date: Fri, 29 Nov 2024 15:28:56 -0600 Subject: [PATCH] fix iavl/v2 reverse iterator --- store/v2/commitment/iavlv2/tree.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/store/v2/commitment/iavlv2/tree.go b/store/v2/commitment/iavlv2/tree.go index 997a0a60cc1a..92f4fdd05b02 100644 --- a/store/v2/commitment/iavlv2/tree.go +++ b/store/v2/commitment/iavlv2/tree.go @@ -109,7 +109,11 @@ func (t *Tree) Iterator(version uint64, start, end []byte, ascending bool) (core if int64(version) != t.tree.Version() { return nil, fmt.Errorf("loading past version not yet supported") } - return t.tree.Iterator(start, end, ascending) + if ascending { + return t.tree.Iterator(start, end, false) + } else { + return t.tree.ReverseIterator(start, end) + } } func (t *Tree) Export(version uint64) (commitment.Exporter, error) {