From 60a8538e0ca744e8fa9584bc1777031ca5b1f685 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Sat, 9 Oct 2021 11:01:26 +0200 Subject: [PATCH] P2PServer: show an error when there are no ZMQ messages --- src/p2p_server.cpp | 16 ++++++++++++++++ src/p2p_server.h | 1 + src/p2pool.cpp | 6 ++++++ src/p2pool.h | 4 ++++ 4 files changed, 27 insertions(+) diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index c81ce24..da1e700 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -679,6 +679,7 @@ void P2PServer::on_timer() update_peer_list(); save_peer_list_async(); update_peer_connections(); + check_zmq(); } void P2PServer::flush_cache() @@ -779,6 +780,21 @@ void P2PServer::download_missing_blocks() } } +void P2PServer::check_zmq() +{ + if ((m_timerCounter % 30) != 0) { + return; + } + + const time_t cur_time = time(nullptr); + const time_t last_active = m_pool->zmq_last_active(); + + if (cur_time >= last_active + 300) { + const uint64_t dt = static_cast(cur_time - last_active); + LOGERR(1, "no ZMQ messages received from monerod in the last " << dt << " seconds, check your monerod/p2pool/network/firewall setup!!!"); + } +} + P2PServer::P2PClient::P2PClient() : m_peerId(0) , m_expectedMessage(MessageId::HANDSHAKE_CHALLENGE) diff --git a/src/p2p_server.h b/src/p2p_server.h index 5131381..9a8aa9d 100644 --- a/src/p2p_server.h +++ b/src/p2p_server.h @@ -139,6 +139,7 @@ private: void flush_cache(); void download_missing_blocks(); + void check_zmq(); void update_peer_connections(); void update_peer_list(); void save_peer_list_async(); diff --git a/src/p2pool.cpp b/src/p2pool.cpp index 57db6b9..b043f04 100644 --- a/src/p2pool.cpp +++ b/src/p2pool.cpp @@ -173,6 +173,8 @@ void p2pool::handle_tx(TxMempoolData& tx) #if TEST_MEMPOOL_PICKING_ALGORITHM m_blockTemplate->update(m_minerData, *m_mempool, &m_params->m_wallet); #endif + + m_zmqLastActive = time(nullptr); } void p2pool::handle_miner_data(MinerData& data) @@ -226,6 +228,8 @@ void p2pool::handle_miner_data(MinerData& data) else { update_block_template(); } + + m_zmqLastActive = time(nullptr); } const char* BLOCK_FOUND = "\n\ @@ -288,6 +292,8 @@ void p2pool::handle_chain_main(ChainMain& data, const char* extra) } api_update_network_stats(); + + m_zmqLastActive = time(nullptr); } void p2pool::submit_block_async(uint32_t template_id, uint32_t nonce, uint32_t extra_nonce) diff --git a/src/p2pool.h b/src/p2pool.h index 2e3b58e..2e921b4 100644 --- a/src/p2pool.h +++ b/src/p2pool.h @@ -78,6 +78,8 @@ public: bool get_difficulty_at_height(uint64_t height, difficulty_type& diff); + time_t zmq_last_active() const { return m_zmqLastActive; } + private: p2pool(const p2pool&) = delete; p2pool(p2pool&&) = delete; @@ -167,6 +169,8 @@ private: uv_async_t m_submitBlockAsync; uv_async_t m_blockTemplateAsync; uv_async_t m_stopAsync; + + time_t m_zmqLastActive = 0; }; } // namespace p2pool