Implement getNearest methods
PR description
Add getNearestAfter method needed for verkle and fix getNearestBefore method
Fixed Issue(s)
Thanks for sending a pull request! Have you done the following?
- [ ] Checked out our contribution guidelines?
- [ ] Considered documentation and added the
doc-change-requiredlabel to this PR if updates are required. - [ ] Considered the changelog and included an update if required.
- [ ] For database changes (e.g. KeyValueSegmentIdentifier) considered compatibility and performed forwards and backwards compatibility tests
Locally, you can run these tests to catch failures early:
- [ ] unit tests:
./gradlew build - [ ] acceptance tests:
./gradlew acceptanceTest - [ ] integration tests:
./gradlew integrationTest - [ ] reference tests:
./gradlew ethereum:referenceTests:referenceTests
Generally LGTM. the rewrite of getNearest seems a little chat-gpt-y to me though
Thanks for the review.. Can you also tell me what bothers so that I can change. Is factorization too hard to understand ?
The use of Min Max on this case is more interesting because it avoids sorting that would be more expensive. This is why this proposal seems to me more interesting for this call. But I can understand that the overall factorization of the method is complex and I can try to simplify by duplicating more
@garyschulte did some cleanning in the PR, I also modified the tests in order to check more edgcases, the new tests are comparing directly with rocksdb instead of hardcoding the responses
thanks to that I fixed some new issues
The use of Min Max on this case is more interesting because it avoids sorting that would be more expensive.
that makes a lot of sense, min/max will be O(n). 👍
@garyschulte is this GTG?
yes will fix the PR