From 40430febc55b7b728cb8da65a16ba2c77cfbdafe Mon Sep 17 00:00:00 2001 From: Matt Kocubinski Date: Sun, 1 Dec 2024 12:49:31 -0600 Subject: [PATCH] fix(store/v2): iavl/v2 reverse iterator (#22699) Co-authored-by: Marko --- 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 14b7967a6c78..43c25a23a2c8 100644 --- a/store/v2/commitment/iavlv2/tree.go +++ b/store/v2/commitment/iavlv2/tree.go @@ -113,7 +113,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) {