From f5e4f00f8b1dbee50b4527c96bdcff6dee148ed5 Mon Sep 17 00:00:00 2001 From: ledhed2222 Date: Sat, 25 Mar 2023 01:09:19 -0400 Subject: [PATCH] remove hacky throttling --- src/main/main.cpp | 55 ++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/src/main/main.cpp b/src/main/main.cpp index da2852f0f..ad77b9ad2 100644 --- a/src/main/main.cpp +++ b/src/main/main.cpp @@ -10,29 +10,28 @@ #include -int -maybeWaitAfterWrite( - int justWrote, - int written, - boost::asio::steady_timer& timer) +void +doNFTWrite( + std::vector& nfts, + Backend::CassandraBackend& backend, + std::string const tag) { - written = written + justWrote; - if (written > 10000) + if (nfts.size() > 0) { - BOOST_LOG_TRIVIAL(info) << "Waiting on throttling..."; - timer.expires_after(std::chrono::seconds(60)); - timer.wait(); - BOOST_LOG_TRIVIAL(info) << "...done waiting"; - written = 0; + BOOST_LOG_TRIVIAL(info) + << tag << ": About to write " << nfts.size() << " records..."; + backend.writeNFTs(std::move(nfts)); + backend.sync(); + BOOST_LOG_TRIVIAL(info) << tag << ": Done"; } - return written; + else + BOOST_LOG_TRIVIAL(info) << tag << ": No records to write"; } void doMigration( Backend::CassandraBackend& backend, - boost::asio::yield_context yield, - boost::asio::steady_timer& timer) + boost::asio::yield_context yield) { BOOST_LOG_TRIVIAL(info) << "Beginning migration"; /* @@ -46,8 +45,6 @@ doMigration( return; } - int written = 0; - /* * Step 1 - Look at all NFT transactions, recording in * `nf_token_transactions` and reload any NFTokenMint transactions. These @@ -128,14 +125,7 @@ doMigration( } // write what we have - if (toWrite.size() > 0) - { - backend.writeNFTs(std::move(toWrite)); - backend.sync(); - BOOST_LOG_TRIVIAL(info) - << "TXS: Wrote " << toWrite.size() << " records"; - written = maybeWaitAfterWrite(toWrite.size(), written, timer); - } + doNFTWrite(toWrite, backend, "TX"); morePages = cass_result_has_more_pages(result); if (morePages) @@ -167,14 +157,7 @@ doMigration( ledgerRange->minSequence, ripple::to_string(object.key), blobStr); - if (toWrite.size() > 0) - { - backend.writeNFTs(std::move(toWrite)); - backend.sync(); - BOOST_LOG_TRIVIAL(info) - << "OBJS: Wrote " << toWrite.size() << " records"; - written = maybeWaitAfterWrite(toWrite.size(), written, timer); - } + doNFTWrite(toWrite, backend, "OBJ"); } cursor = page.cursor; } while (cursor.has_value()); @@ -238,12 +221,10 @@ main(int argc, char* argv[]) boost::asio::io_context ioc; auto backend = Backend::make_Backend(ioc, config); - boost::asio::steady_timer timer(ioc); - auto work = boost::asio::make_work_guard(ioc); boost::asio::spawn( - ioc, [&backend, &work, &timer](boost::asio::yield_context yield) { - doMigration(*backend, yield, timer); + ioc, [&backend, &work](boost::asio::yield_context yield) { + doMigration(*backend, yield); work.reset(); });