mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Return a validated ledger if there is one (RIPD-814)
LedgerMaster::getLedgerBySeq should return a validated ledger (rather than the the open or closed ledger) for a sequence number for which it has a fully-validated ledger.
This commit is contained in:
@@ -1448,6 +1448,28 @@ public:
|
||||
|
||||
Ledger::pointer getLedgerBySeq (std::uint32_t index)
|
||||
{
|
||||
if (index <= mValidLedgerSeq)
|
||||
{
|
||||
// Always prefer a validated ledger
|
||||
auto valid = mValidLedger.get ();
|
||||
if (valid)
|
||||
{
|
||||
if (valid->getLedgerSeq() == index)
|
||||
return valid;
|
||||
|
||||
try
|
||||
{
|
||||
uint256 const& hash = valid->getLedgerHash (index);
|
||||
if (hash.isNonZero())
|
||||
return mLedgerHistory.getLedgerByHash (hash);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
// Missing nodes are already handled
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ledger::pointer ret = mLedgerHistory.getLedgerBySeq (index);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
Reference in New Issue
Block a user