MCPcopy Create free account
hub / github.com/bitshares/bitshares-core / add_node

Method add_node

libraries/net/node.cpp:4413–4435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4411 }
4412
4413 void node_impl::add_node(const fc::ip::endpoint& ep)
4414 {
4415 VERIFY_CORRECT_THREAD();
4416 // if we're connecting to them, we believe they're not firewalled
4417 auto updated_peer_record = _potential_peer_db.lookup_or_create_entry_for_ep(ep);
4418
4419 // if we've recently connected to this peer, reset the last_connection_attempt_time to allow
4420 // us to immediately retry this peer
4421 // Note: to make it work, we need to multiply _peer_connection_retry_timeout
4422 // by number_of_failed_connection_attempts.
4423 // However, this step is almost useless because we will immediately try to connect anyway
4424 // due to _add_once_node_list.
4425 // On the other hand, if we connected to the peer already but it was not in the peer database somehow,
4426 // this step makes sure that it will be added to the peer database.
4427 auto delay_until_retry = fc::seconds( (updated_peer_record.number_of_failed_connection_attempts + 1)
4428 * _peer_connection_retry_timeout );
4429 updated_peer_record.last_connection_attempt_time
4430 = std::min<fc::time_point_sec>( updated_peer_record.last_connection_attempt_time,
4431 fc::time_point::now() - delay_until_retry );
4432 _add_once_node_list.push_back(updated_peer_record);
4433 _potential_peer_db.update_entry(updated_peer_record);
4434 trigger_p2p_network_connect_loop();
4435 }
4436
4437 void node_impl::add_seed_node(const std::string& endpoint_string)
4438 {

Callers

nothing calls this directly

Calls 2

update_entryMethod · 0.80

Tested by

no test coverage detected