ZMQReader: start after initial RPC calls are finished

This commit is contained in:
SChernykh 2021-10-28 20:05:40 +02:00
parent a008eac8c6
commit da4686b88f
2 changed files with 5 additions and 1 deletions

View file

@ -533,6 +533,7 @@ void p2pool::download_block_headers(uint64_t current_height)
if (parse_block_headers_range(data, size) == BLOCK_HEADERS_REQUIRED) { if (parse_block_headers_range(data, size) == BLOCK_HEADERS_REQUIRED) {
update_median_timestamp(); update_median_timestamp();
if (m_serversStarted.exchange(1) == 0) { if (m_serversStarted.exchange(1) == 0) {
m_ZMQReader = new ZMQReader(m_params->m_host.c_str(), m_params->m_zmqPort, this);
m_stratumServer = new StratumServer(this); m_stratumServer = new StratumServer(this);
m_p2pServer = new P2PServer(this); m_p2pServer = new P2PServer(this);
api_update_network_stats(); api_update_network_stats();
@ -1222,11 +1223,11 @@ int p2pool::run()
} }
try { try {
ZMQReader z(m_params->m_host.c_str(), m_params->m_zmqPort, this);
get_info(); get_info();
load_found_blocks(); load_found_blocks();
const int rc = uv_run(uv_default_loop_checked(), UV_RUN_DEFAULT); const int rc = uv_run(uv_default_loop_checked(), UV_RUN_DEFAULT);
LOGINFO(1, "uv_run exited, result = " << rc); LOGINFO(1, "uv_run exited, result = " << rc);
delete m_ZMQReader;
} }
catch (const std::exception& e) { catch (const std::exception& e) {
const char* s = e.what(); const char* s = e.what();

View file

@ -31,6 +31,7 @@ class StratumServer;
class P2PServer; class P2PServer;
class ConsoleCommands; class ConsoleCommands;
class p2pool_api; class p2pool_api;
class ZMQReader;
class p2pool : public MinerCallbackHandler class p2pool : public MinerCallbackHandler
{ {
@ -172,6 +173,8 @@ private:
time_t m_zmqLastActive; time_t m_zmqLastActive;
time_t m_startTime; time_t m_startTime;
ZMQReader* m_ZMQReader = nullptr;
}; };
} // namespace p2pool } // namespace p2pool