You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To address this issue, we can add a new method, GetNearest to the DB interface and implement it for all supported storage engines. This method should have a similar cost to the Get operation and provide a more efficient alternative to iterators for finding the nearest key.
// GetNearest retrieves the nearest key to the given key.
// If 'ascending' is true, the method returns the smallest key greater than the given key.
// If 'ascending' is false, the method returns the largest key smaller than the given key.
// In case there is no key in the desired direction, the method returns nil.
// CONTRACT: key, value read-only []byte
GetNearest(key []byte, ascending bool) ([]byte, error)
Once implemented, the method can be used in the cosmos-sdk repo to add a GetNearest function to the KVStore interface, as described in the original issue.
The text was updated successfully, but these errors were encountered:
@elias-orijtech
Not yet.
I was uncertain whether I correctly understood the concept and if the problem is still relevant considering the age of the original issue.
Hence, I decided to verify it by opening this discussion first.
Summary
There is an issue in cosmos-sdk: Make KVStore interface have methods to getNearest entry.
To address this issue, we can add a new method, GetNearest to the DB interface and implement it for all supported storage engines. This method should have a similar cost to the Get operation and provide a more efficient alternative to iterators for finding the nearest key.
Once implemented, the method can be used in the cosmos-sdk repo to add a GetNearest function to the KVStore interface, as described in the original issue.
The text was updated successfully, but these errors were encountered: