mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-11-17 00:07:47 +00:00
Update check now also checks for connected peer versions
This commit is contained in:
parent
e5770a5343
commit
294d1a525e
2 changed files with 14 additions and 1 deletions
|
@ -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<raw_ip> 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> 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() << "********************************************************************************");
|
||||
|
|
|
@ -261,6 +261,7 @@ private:
|
|||
unordered_set<uint64_t> m_blockNotifyRequests;
|
||||
|
||||
P2PClient* m_fastestPeer;
|
||||
std::atomic<bool> m_newP2PoolVersionDetected;
|
||||
|
||||
static void on_broadcast(uv_async_t* handle) { reinterpret_cast<P2PServer*>(handle->data)->on_broadcast(); }
|
||||
void on_broadcast();
|
||||
|
|
Loading…
Reference in a new issue