From 69a8793fa40d4785762cc00379aeaa01b3bf28ff Mon Sep 17 00:00:00 2001 From: Jasmina Malicevic Date: Thu, 22 Dec 2022 00:01:10 +0100 Subject: [PATCH] Added clarification comments --- state/indexer/block/kv/util.go | 4 ++++ state/indexer/query_range.go | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/state/indexer/block/kv/util.go b/state/indexer/block/kv/util.go index 3eac2d7b0..0f72a0f8d 100644 --- a/state/indexer/block/kv/util.go +++ b/state/indexer/block/kv/util.go @@ -142,6 +142,10 @@ func lookForHeight(conditions []query.Condition) (int64, bool, int) { return 0, false, -1 } +// Remove all occurrences of height equality queries except one. While we are traversing the conditions, check whether the only condition in +// addition to match events is the height equality or height range query. At the same time, if we do have a height range condition +// ignore the height equality condition. If a height equality exists, place the condition index in the query and the desired height +// into the heightInfo struct func dedupHeight(conditions []query.Condition) (dedupConditions []query.Condition, heightInfo HeightInfo, found bool) { heightInfo.heightEqIdx = -1 heightRangeExists := false diff --git a/state/indexer/query_range.go b/state/indexer/query_range.go index 98931a799..5b75c04b5 100644 --- a/state/indexer/query_range.go +++ b/state/indexer/query_range.go @@ -77,7 +77,8 @@ func (qr QueryRange) UpperBoundValue() interface{} { } // LookForRanges returns a mapping of QueryRanges and the matching indexes in -// the provided query conditions. +// the provided query conditions. If we are matching attributes within events +// we need to remember the height range from the condition func LookForRanges(conditions []query.Condition) (ranges QueryRanges, indexes []int, heightRange QueryRange) { ranges = make(QueryRanges) for i, c := range conditions {