mirror of
https://github.com/SChernykh/p2pool.git
synced 2025-01-18 08:34:30 +00:00
P2PServer: check protocol version when choosing fastest peer
This commit is contained in:
parent
fe2ff95f19
commit
1219ed0dd6
1 changed files with 11 additions and 3 deletions
|
@ -298,8 +298,16 @@ void P2PServer::update_peer_connections()
|
||||||
connected_clients.insert(client->m_addr);
|
connected_clients.insert(client->m_addr);
|
||||||
if (client->is_good()) {
|
if (client->is_good()) {
|
||||||
has_good_peers = true;
|
has_good_peers = true;
|
||||||
if ((client->m_pingTime >= 0) && (!m_fastestPeer || (m_fastestPeer->m_pingTime > client->m_pingTime))) {
|
if (client->m_pingTime >= 0) {
|
||||||
m_fastestPeer = client;
|
if (!m_fastestPeer) {
|
||||||
|
m_fastestPeer = client;
|
||||||
|
}
|
||||||
|
else if (m_fastestPeer->m_protocolVersion < client->m_protocolVersion) {
|
||||||
|
m_fastestPeer = client;
|
||||||
|
}
|
||||||
|
else if ((m_fastestPeer->m_protocolVersion == client->m_protocolVersion) && (m_fastestPeer->m_pingTime > client->m_pingTime)) {
|
||||||
|
m_fastestPeer = client;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2511,7 +2519,7 @@ void P2PServer::P2PClient::post_handle_incoming_block(const uint32_t reset_count
|
||||||
|
|
||||||
// If the initial sync is not finished yet, try to ask the fastest peer too
|
// If the initial sync is not finished yet, try to ask the fastest peer too
|
||||||
P2PClient* c = server->m_fastestPeer;
|
P2PClient* c = server->m_fastestPeer;
|
||||||
if (c && (c != this) && !server->m_pool->side_chain().precalcFinished()) {
|
if (c && (c != this) && (c->m_protocolVersion >= m_protocolVersion) && !server->m_pool->side_chain().precalcFinished()) {
|
||||||
LOGINFO(5, "peer " << static_cast<char*>(c->m_addrString) << " is faster, sending BLOCK_REQUEST to it too");
|
LOGINFO(5, "peer " << static_cast<char*>(c->m_addrString) << " is faster, sending BLOCK_REQUEST to it too");
|
||||||
c->post_handle_incoming_block(c->m_resetCounter.load(), missing_blocks);
|
c->post_handle_incoming_block(c->m_resetCounter.load(), missing_blocks);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue