mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-08-19 21:18:46 -06:00
P2PServer: removed protocol version check for fastest peer
This commit is contained in:
parent
32dc235aa5
commit
75cc82ae0c
@ -298,16 +298,8 @@ 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) {
|
if ((client->m_pingTime >= 0) && (!m_fastestPeer || (m_fastestPeer->m_pingTime > client->m_pingTime))) {
|
||||||
if (!m_fastestPeer) {
|
m_fastestPeer = client;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2115,6 +2107,9 @@ bool P2PServer::P2PClient::on_block_response(const uint8_t* buf, uint32_t size,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_broadcastMaxHeight = std::max(m_broadcastMaxHeight, block->m_sidechainHeight);
|
||||||
|
m_broadcastedHashes[m_broadcastedHashesIndex++ % array_size(&P2PClient::m_broadcastedHashes)] = block->m_sidechainId;
|
||||||
|
|
||||||
if (cur_time >= m_nextOutgoingPeerListRequest) {
|
if (cur_time >= m_nextOutgoingPeerListRequest) {
|
||||||
server->send_peer_list_request(this, cur_time);
|
server->send_peer_list_request(this, cur_time);
|
||||||
}
|
}
|
||||||
@ -2527,7 +2522,7 @@ void P2PServer::P2PClient::post_handle_incoming_block(const PoolBlock& block, co
|
|||||||
// If the initial sync is not finished yet, try to ask the fastest peer instead
|
// If the initial sync is not finished yet, try to ask the fastest peer instead
|
||||||
if (!server->m_pool->side_chain().precalcFinished()) {
|
if (!server->m_pool->side_chain().precalcFinished()) {
|
||||||
P2PClient* c = server->m_fastestPeer;
|
P2PClient* c = server->m_fastestPeer;
|
||||||
if (c && (c != this) && (c->m_protocolVersion >= m_protocolVersion) && (c->m_broadcastMaxHeight >= block.m_sidechainHeight)) {
|
if (c && (c != this) && (c->m_broadcastMaxHeight >= block.m_sidechainHeight)) {
|
||||||
LOGINFO(5, "peer " << static_cast<char*>(c->m_addrString) << " is faster, sending BLOCK_REQUEST to it instead");
|
LOGINFO(5, "peer " << static_cast<char*>(c->m_addrString) << " is faster, sending BLOCK_REQUEST to it instead");
|
||||||
c->post_handle_incoming_block(block, c->m_resetCounter.load(), missing_blocks);
|
c->post_handle_incoming_block(block, c->m_resetCounter.load(), missing_blocks);
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user