mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 02:25:53 +00:00
use ordered ledgers_ map for faster first txn lookup
This commit is contained in:
@@ -65,17 +65,12 @@ public:
|
|||||||
return {};
|
return {};
|
||||||
|
|
||||||
std::shared_lock<std::shared_mutex> lock(mutex_);
|
std::shared_lock<std::shared_mutex> lock(mutex_);
|
||||||
LedgerIndex minSeq = std::numeric_limits<LedgerIndex>::max();
|
for (const auto& [ledgerSeq, ledgerData] : ledgers_)
|
||||||
if (transactionMap_.empty())
|
|
||||||
return std::nullopt;
|
|
||||||
for (const auto& [_, txMeta] : transactionMap_)
|
|
||||||
{
|
{
|
||||||
if (txMeta.second && txMeta.second->getLgrSeq() < minSeq)
|
if (!ledgerData.transactions.empty())
|
||||||
minSeq = txMeta.second->getLgrSeq();
|
return ledgerSeq;
|
||||||
}
|
}
|
||||||
return minSeq == std::numeric_limits<LedgerIndex>::max()
|
return std::nullopt;
|
||||||
? std::nullopt
|
|
||||||
: std::optional<LedgerIndex>(minSeq);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<LedgerIndex>
|
std::optional<LedgerIndex>
|
||||||
|
|||||||
Reference in New Issue
Block a user