From 1340df1c0dc2d35d57a7c9654f2b360a4528dc37 Mon Sep 17 00:00:00 2001 From: abitmore Date: Mon, 3 May 2021 11:19:29 +0000 Subject: [PATCH 1/2] Remove unavailable item from active sync requests When got an `item_not_available_message` from a peer, the item was removed from the `sync_items_requested_from_peer` list of the peer, but it was left in the `_active_sync_requests` list. When disconnecting from the peer, since the `sync_items_requested_from_peer` list of the peer no longer contains the item, the cleanup process does not remove it from the `_active_sync_requests` list either. As a result, the node will not request the item from another peer, thus gets stuck. --- libraries/net/node.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 034779a8c4..381dc863af 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -2359,6 +2359,7 @@ namespace graphene { namespace net { namespace detail { auto sync_item_iter = originating_peer->sync_items_requested_from_peer.find(requested_item.item_hash); if (sync_item_iter != originating_peer->sync_items_requested_from_peer.end()) { + _active_sync_requests.erase(*sync_item_iter); originating_peer->sync_items_requested_from_peer.erase(sync_item_iter); if (originating_peer->peer_needs_sync_items_from_us) From ba707b3f5e66e4c137aaa7737ef418eab3f567ed Mon Sep 17 00:00:00 2001 From: abitmore Date: Mon, 3 May 2021 12:35:03 +0000 Subject: [PATCH 2/2] Fix code smells --- libraries/net/node.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/net/node.cpp b/libraries/net/node.cpp index 381dc863af..18ee890cf3 100644 --- a/libraries/net/node.cpp +++ b/libraries/net/node.cpp @@ -1610,7 +1610,7 @@ namespace graphene { namespace net { namespace detail { originating_peer->send_message(address_request_message()); fc::time_point now = fc::time_point::now(); if (_is_firewalled == firewalled_state::unknown && - _last_firewall_check_message_sent < now - fc::minutes(5) && + _last_firewall_check_message_sent < (now - fc::minutes(5)) && originating_peer->core_protocol_version >= 106) { wlog("I don't know if I'm firewalled. Sending a firewall check message to peer ${peer}", @@ -2169,7 +2169,7 @@ namespace graphene { namespace net { namespace detail { originating_peer->last_block_time_delegate_has_seen + // timestamp of the block immediately before the first unfetched block originating_peer->number_of_unfetched_item_ids * GRAPHENE_MIN_BLOCK_INTERVAL; fc::time_point_sec now = fc::time_point::now(); - if (minimum_time_of_last_offered_block > now + GRAPHENE_NET_FUTURE_SYNC_BLOCKS_GRACE_PERIOD_SEC) + if (minimum_time_of_last_offered_block > (now + GRAPHENE_NET_FUTURE_SYNC_BLOCKS_GRACE_PERIOD_SEC)) { wlog("Disconnecting from peer ${peer} who offered us an implausible number of blocks, their last block would be in the future (${timestamp})", ("peer", originating_peer->get_remote_endpoint())