Implement server_info nextgen RPC (#590)

Fixes #587
This commit is contained in:
Alex Kremer
2023-04-13 11:51:54 +01:00
committed by GitHub
parent dfe974d5ab
commit 36bb20806e
18 changed files with 1062 additions and 88 deletions

View File

@@ -18,10 +18,13 @@
//==============================================================================
#include "TestObject.h"
#include <backend/DBHelpers.h>
#include <ripple/protocol/STArray.h>
#include <ripple/protocol/TER.h>
#include <chrono>
ripple::AccountID
GetAccountIDWithString(std::string_view id)
{
@@ -29,11 +32,21 @@ GetAccountIDWithString(std::string_view id)
}
ripple::LedgerInfo
CreateLedgerInfo(std::string_view ledgerHash, ripple::LedgerIndex seq)
CreateLedgerInfo(std::string_view ledgerHash, ripple::LedgerIndex seq, std::optional<uint32_t> age)
{
using namespace std::chrono;
auto ledgerinfo = ripple::LedgerInfo();
ledgerinfo.hash = ripple::uint256{ledgerHash};
ledgerinfo.seq = seq;
if (age)
{
auto const now = duration_cast<seconds>(system_clock::now().time_since_epoch());
auto const closeTime = (now - seconds{age.value()}).count() - rippleEpochStart;
ledgerinfo.closeTime = ripple::NetClock::time_point{seconds{closeTime}};
}
return ledgerinfo;
}