make keysRepair async

This commit is contained in:
CJ Cobb
2021-05-29 16:53:15 -04:00
parent 756436dd31
commit 9a4949263e
2 changed files with 15 additions and 2 deletions

View File

@@ -74,6 +74,15 @@ BackendIndexer::doKeysRepair(
BOOST_LOG_TRIVIAL(info)
<< __func__ << " finished. sequence = " << std::to_string(*sequence);
}
void
BackendIndexer::doKeysRepairAsync(
BackendInterface const& backend,
std::optional<uint32_t> sequence)
{
boost::asio::post(ioc_, [this, sequence, &backend]() {
doKeysRepair(backend, sequence);
});
}
void
BackendIndexer::writeKeyFlagLedgerAsync(

View File

@@ -88,6 +88,10 @@ class BackendIndexer
std::unordered_set<ripple::uint256> keys;
mutable bool isFirst_ = true;
void
doKeysRepair(
BackendInterface const& backend,
std::optional<uint32_t> sequence);
public:
BackendIndexer(boost::json::object const& config);
@@ -103,7 +107,7 @@ public:
uint32_t ledgerSequence,
BackendInterface const& backend);
void
doKeysRepair(
doKeysRepairAsync(
BackendInterface const& backend,
std::optional<uint32_t> sequence);
uint32_t
@@ -171,7 +175,7 @@ public:
auto rng = fetchLedgerRangeNoThrow();
if (rng && rng->minSequence != ledgerSequence)
isFirst_ = false;
indexer_.doKeysRepair(*this, ledgerSequence);
indexer_.doKeysRepairAsync(*this, ledgerSequence);
}
if (indexer_.isKeyFlagLedger(ledgerSequence) || isFirst_)
indexer_.writeKeyFlagLedgerAsync(ledgerSequence, *this);