From 9431fe1b9414d32ea9d09dc602131349f5f8af76 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Thu, 30 Mar 2023 09:51:59 +0700 Subject: [PATCH] e3: history iterator shortcut fix (#960) --- state/history.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/state/history.go b/state/history.go index ede0e5cc8..15a72b23b 100644 --- a/state/history.go +++ b/state/history.go @@ -1862,6 +1862,7 @@ func (hc *HistoryContext) iterateChangedFrozen(fromTxNum, toTxNum int, asc order if len(hc.ic.files) == 0 { return iter.EmptyKV, nil } + if fromTxNum >= 0 && hc.ic.files[len(hc.ic.files)-1].endTxNum <= uint64(fromTxNum) { return iter.EmptyKV, nil } @@ -1897,10 +1898,11 @@ func (hc *HistoryContext) iterateChangedFrozen(fromTxNum, toTxNum int, asc order } func (hc *HistoryContext) iterateChangedRecent(fromTxNum, toTxNum int, asc order.By, limit int, roTx kv.Tx) (iter.KV, error) { - if asc == false { + if asc == order.Desc { panic("not supported yet") } - if len(hc.ic.files) > 0 && (fromTxNum >= 0 && hc.ic.files[len(hc.ic.files)-1].endTxNum >= uint64(fromTxNum)) { + rangeIsInFiles := toTxNum >= 0 && len(hc.ic.files) > 0 && hc.ic.files[len(hc.ic.files)-1].endTxNum >= uint64(toTxNum) + if rangeIsInFiles { return iter.EmptyKV, nil } if hc.h.largeValues {