core: allow to perform storage search within given amount of DAO layers

This commit is contained in:
Anna Shaleva 2022-10-05 13:42:15 +03:00
parent 8c78177806
commit 0db4e8d62c
2 changed files with 11 additions and 1 deletions

View file

@ -301,7 +301,12 @@ func performSeek(ctx context.Context, ps Store, memRes []KeyValueExists, rng See
}
}
}
ps.Seek(rng, mergeFunc)
if rng.SearchDepth == 0 || rng.SearchDepth > 1 {
if rng.SearchDepth > 1 {
rng.SearchDepth--
}
ps.Seek(rng, mergeFunc)
}
if !done && haveMem {
loop:

View file

@ -59,6 +59,11 @@ type SeekRange struct {
// whether seeking should be performed in a descending way.
// Backwards can be safely combined with Prefix and Start.
Backwards bool
// SearchDepth is the depth of Seek operation, denotes the number of cached
// DAO layers to perform search. Use 1 to fetch the latest changes from upper
// in-memory layer of cached DAO. Default 0 value denotes searching through
// the whole set of cached layers.
SearchDepth int
}
// ErrKeyNotFound is an error returned by Store implementations