New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
R4R: Swap start/end in ReverseIterator #2913
Conversation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Codecov Report
@@ Coverage Diff @@
## develop #2913 +/- ##
===========================================
- Coverage 62.15% 62.08% -0.08%
===========================================
Files 212 212
Lines 17369 17255 -114
===========================================
- Hits 10796 10712 -84
+ Misses 5663 5639 -24
+ Partials 910 904 -6
|
var end = itr.end | ||
var key = itr.source.Key() | ||
if itr.isReverse { | ||
if end != nil && bytes.Compare(key, end) <= 0 { | ||
if start != nil && bytes.Compare(key, start) < 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think we need the start != nil
check here anymore, but doesn't hurt
@@ -310,7 +296,6 @@ func (itr *prefixIterator) Next() { | |||
} | |||
itr.source.Next() | |||
if !itr.source.Valid() || !bytes.HasPrefix(itr.source.Key(), itr.prefix) { | |||
itr.source.Close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was there some reason for this to be here in the first place ?
This makes dbm.DB.ReverseIterator have the same API as the cosmos sdk's store.Store.ReverseIterator (they share the same interface, as that was the intent).
It turns out that the CosmosSDK's store.Store.ReverseIterator API as currently implemented is both different and better than what we have now in tendermint/libs/db.
With this PR, the CosmosSDK can use the tendermint/libs/db.DB as a store.Store using the db adapter in the SDK, which is needed for faster simulation (as a non-production drop-in replacement for the IAVL store in cosmos-sdk/store.IAVLStore).
See also: