diff --git a/src/p2p_server.cpp b/src/p2p_server.cpp index 9d99a7f..1632d04 100644 --- a/src/p2p_server.cpp +++ b/src/p2p_server.cpp @@ -59,6 +59,7 @@ P2PServer::P2PServer(p2pool* pool) , m_peerListLastSaved(0) , m_lookForMissingBlocks(true) , m_fastestPeer(nullptr) + , m_newP2PoolVersionDetected(false) { m_callbackBuf.resize(P2P_BUF_SIZE); m_blockDeserializeBuf.reserve(MAX_BLOCK_SIZE); @@ -270,6 +271,9 @@ void P2PServer::update_peer_connections() bool has_good_peers = false; m_fastestPeer = nullptr; + uint64_t total_outgoing_p2pool = 0; + uint64_t newer_version_p2pool = 0; + unordered_set connected_clients; connected_clients.reserve(m_numConnections); @@ -303,9 +307,17 @@ void P2PServer::update_peer_connections() if ((client->m_pingTime >= 0) && (!m_fastestPeer || (m_fastestPeer->m_pingTime > client->m_pingTime))) { m_fastestPeer = client; } + if ((client->m_SoftwareID == SoftwareID::P2Pool) && client->m_SoftwareVersion && !client->m_isIncoming) { + ++total_outgoing_p2pool; + if (client->m_SoftwareVersion > ((P2POOL_VERSION_MAJOR << 16) | P2POOL_VERSION_MINOR)) { + ++newer_version_p2pool; + } + } } } + m_newP2PoolVersionDetected = newer_version_p2pool * 5 > total_outgoing_p2pool; + std::vector peer_list; { MutexLock lock(m_peerListLock); @@ -1270,7 +1282,7 @@ void P2PServer::check_for_updates(bool forced) const const SideChain& s = m_pool->side_chain(); - if ((forced || s.precalcFinished()) && s.p2pool_update_available()) { + if ((forced || s.precalcFinished()) && m_newP2PoolVersionDetected && s.p2pool_update_available()) { LOGINFO(0, log::LightCyan() << "********************************************************************************"); LOGINFO(0, log::LightCyan() << "* An updated P2Pool version is available, visit p2pool.io for more information *"); LOGINFO(0, log::LightCyan() << "********************************************************************************"); diff --git a/src/p2p_server.h b/src/p2p_server.h index 4517737..f5c9896 100644 --- a/src/p2p_server.h +++ b/src/p2p_server.h @@ -261,6 +261,7 @@ private: unordered_set m_blockNotifyRequests; P2PClient* m_fastestPeer; + std::atomic m_newP2PoolVersionDetected; static void on_broadcast(uv_async_t* handle) { reinterpret_cast(handle->data)->on_broadcast(); } void on_broadcast();