#501 on_connection_closed - clear maps of connections

This commit is contained in:
Vlad Dobromyslov 2023-03-14 10:29:38 +03:00
parent c421453621
commit 5203869a9d

View file

@ -3215,35 +3215,6 @@ namespace graphene { namespace net { namespace detail {
}
}
_closing_connections.erase(originating_peer_ptr);
_handshaking_connections.erase(originating_peer_ptr);
_terminating_connections.erase(originating_peer_ptr);
if (_active_connections.find(originating_peer_ptr) != _active_connections.end())
{
_active_connections.erase(originating_peer_ptr);
if (inbound_endpoint && originating_peer_ptr->get_remote_endpoint())
{
fc::optional<potential_peer_record> updated_peer_record = _potential_peer_db.lookup_entry_for_endpoint(*inbound_endpoint);
if (updated_peer_record)
{
updated_peer_record->last_seen_time = fc::time_point::now();
_potential_peer_db.update_entry(*updated_peer_record);
}
}
}
ilog("Remote peer ${endpoint} closed their connection to us", ("endpoint", originating_peer->get_remote_endpoint()));
display_current_connections();
trigger_p2p_network_connect_loop();
// notify the node delegate so it can update the display
if( _active_connections.size() != _last_reported_number_of_connections )
{
_last_reported_number_of_connections = (uint32_t)_active_connections.size();
_delegate->connection_count_changed( _last_reported_number_of_connections );
}
// if we had delegated a firewall check to this peer, send it to another peer
if (originating_peer->firewall_check_state)
{
@ -3281,6 +3252,36 @@ namespace graphene { namespace net { namespace detail {
trigger_fetch_items_loop();
}
if (_active_connections.find(originating_peer_ptr) != _active_connections.end())
{
_active_connections.erase(originating_peer_ptr);
if (inbound_endpoint && originating_peer_ptr->get_remote_endpoint())
{
fc::optional<potential_peer_record> updated_peer_record = _potential_peer_db.lookup_entry_for_endpoint(*inbound_endpoint);
if (updated_peer_record)
{
updated_peer_record->last_seen_time = fc::time_point::now();
_potential_peer_db.update_entry(*updated_peer_record);
}
}
}
// notify the node delegate so it can update the display
if( _active_connections.size() != _last_reported_number_of_connections )
{
_last_reported_number_of_connections = (uint32_t)_active_connections.size();
_delegate->connection_count_changed( _last_reported_number_of_connections );
}
_closing_connections.erase(originating_peer_ptr);
_handshaking_connections.erase(originating_peer_ptr);
_terminating_connections.erase(originating_peer_ptr);
ilog("Remote peer ${endpoint} closed their connection to us", ("endpoint", originating_peer->get_remote_endpoint()));
display_current_connections();
trigger_p2p_network_connect_loop();
schedule_peer_for_deletion(originating_peer_ptr);
}