Skip to content

Conversation

@cindyyan317
Copy link
Contributor

#1052

Feature ledger_index

Return the latest closed ledger index before the given date.
Without any database change, this PR binary search from valid range.
For the full history node, the range is less than 9,000,000 now. The O(n) -> logN should be 27. Comparing with other handlers, it is acceptable.

Example input:

{
 "method": "ledger_index",
 "params": [
     {
       "date":"2024-06-20T09:00:42.000Z"
     }
   ]
}

Example output:

{
  "result":
    {
      "ledger_index": 88816562,
      "ledger_hash": "63911F91F399EFC29E97041477D41B0454159B82EBF0C0223CBE021D89A81D70",
      "closed": "2024-06-20T09:00:42.000Z"
    }
}

@codecov
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

Attention: Patch coverage is 93.54839% with 4 lines in your changes missing coverage. Please review.

Project coverage is 68.15%. Comparing base (d26c93a) to head (243929b).

Files Patch % Lines
src/rpc/handlers/LedgerIndex.hpp 60.00% 0 Missing and 2 partials ⚠️
src/rpc/common/impl/HandlerProvider.cpp 0.00% 1 Missing ⚠️
src/rpc/handlers/LedgerIndex.cpp 97.72% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1503      +/-   ##
===========================================
+ Coverage    67.98%   68.15%   +0.16%     
===========================================
  Files          234      236       +2     
  Lines         9490     9552      +62     
  Branches      5275     5303      +28     
===========================================
+ Hits          6452     6510      +58     
- Misses        1656     1657       +1     
- Partials      1382     1385       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@godexsoft godexsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Leaving a few comments and nits 👍

@cindyyan317 cindyyan317 requested a review from godexsoft July 1, 2024 15:12
godexsoft
godexsoft previously approved these changes Jul 2, 2024
Copy link
Collaborator

@godexsoft godexsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very cool! I'm leaving a few questions, feel free to ignore as it already works as is anyway 🚀

Copy link
Collaborator

@godexsoft godexsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants