Restarting on reorg is broken; fix asio::io_context::restart calls (#177)

This commit is contained in:
Lee *!* Clagett
2025-09-02 11:07:35 -04:00
committed by Lee *!* Clagett
parent 8d854e9bc6
commit 44278d0d11

View File

@@ -960,6 +960,7 @@ namespace lws
std::vector<std::shared_ptr<rpc::scanner::queue>> queues; std::vector<std::shared_ptr<rpc::scanner::queue>> queues;
queues.resize(thread_count); queues.resize(thread_count);
{
struct join_ struct join_
{ {
scanner_sync& self; scanner_sync& self;
@@ -1039,16 +1040,18 @@ namespace lws
rpc::scanner::server::start_user_checking(server); rpc::scanner::server::start_user_checking(server);
if (!lws_server_addr.empty()) if (!lws_server_addr.empty())
rpc::scanner::server::start_acceptor(std::move(server), lws_server_addr, std::move(lws_server_pass)); rpc::scanner::server::start_acceptor(server, lws_server_addr, std::move(lws_server_pass));
// Blocks until sigint, local scanner issue, storage issue, or exception // Blocks until sigint, local scanner issue, storage issue, or exception
self.io_.run();
self.io_.restart(); self.io_.restart();
self.io_.run();
rpc::scanner::server::stop(server);
} // block until all threads join
// Make sure server stops because we could re-start after blockchain sync // Make sure server stops because we could re-start after blockchain sync
rpc::scanner::server::stop(server);
self.io_.poll();
self.io_.restart(); self.io_.restart();
self.io_.poll();
} }
template<typename R, typename Q> template<typename R, typename Q>
@@ -1389,8 +1392,8 @@ namespace lws
the correct timer was run. */ the correct timer was run. */
while (!has_shutdown() && ready.wait_for(std::chrono::seconds{0}) == std::future_status::timeout) while (!has_shutdown() && ready.wait_for(std::chrono::seconds{0}) == std::future_status::timeout)
{ {
sync_.io_.run_one();
sync_.io_.restart(); sync_.io_.restart();
sync_.io_.run_one();
} }
} }
else else