XRPLF / clio

An XRP Ledger API Server
https://xrpl.org
ISC License
56 stars 48 forks source link

feat: Ledger index #1503

Closed cindyyan317 closed 17 hours ago

cindyyan317 commented 4 days ago

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[bot] commented 4 days ago

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 :warning:
src/rpc/common/impl/HandlerProvider.cpp 0.00% 1 Missing :warning:
src/rpc/handlers/LedgerIndex.cpp 97.72% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ 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 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.