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) BOOST_LOG_TRIVIAL(info)
<< __func__ << " finished. sequence = " << std::to_string(*sequence); << __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 void
BackendIndexer::writeKeyFlagLedgerAsync( BackendIndexer::writeKeyFlagLedgerAsync(

View File

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