MCPcopy Create free account
hub / github.com/cryptonomex/graphene / fetch_updated_peer_lists_loop

Method fetch_updated_peer_lists_loop

libraries/net/node.cpp:1498–1531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1496 }
1497
1498 void node_impl::fetch_updated_peer_lists_loop()
1499 {
1500 VERIFY_CORRECT_THREAD();
1501
1502 std::list<peer_connection_ptr> original_active_peers(_active_connections.begin(), _active_connections.end());
1503 for( const peer_connection_ptr& active_peer : original_active_peers )
1504 {
1505 try
1506 {
1507 active_peer->send_message(address_request_message());
1508 }
1509 catch ( const fc::canceled_exception& )
1510 {
1511 throw;
1512 }
1513 catch (const fc::exception& e)
1514 {
1515 dlog("Caught exception while sending address request message to peer ${peer} : ${e}",
1516 ("peer", active_peer->get_remote_endpoint())("e", e));
1517 }
1518 }
1519
1520 // this has nothing to do with updating the peer list, but we need to prune this list
1521 // at regular intervals, this is a fine place to do it.
1522 fc::time_point_sec oldest_failed_ids_to_keep(fc::time_point::now() - fc::minutes(15));
1523 auto oldest_failed_ids_to_keep_iter = _recently_failed_items.get<peer_connection::timestamp_index>().lower_bound(oldest_failed_ids_to_keep);
1524 auto begin_iter = _recently_failed_items.get<peer_connection::timestamp_index>().begin();
1525 _recently_failed_items.get<peer_connection::timestamp_index>().erase(begin_iter, oldest_failed_ids_to_keep_iter);
1526
1527 if (!_node_is_shutting_down && !_fetch_updated_peer_lists_loop_done.canceled() )
1528 _fetch_updated_peer_lists_loop_done = fc::schedule( [this](){ fetch_updated_peer_lists_loop(); },
1529 fc::time_point::now() + fc::minutes(15),
1530 "fetch_updated_peer_lists_loop" );
1531 }
1532 void node_impl::update_bandwidth_data(uint32_t bytes_read_this_second, uint32_t bytes_written_this_second)
1533 {
1534 VERIFY_CORRECT_THREAD();

Callers

nothing calls this directly

Calls 7

nowFunction · 0.85
eraseMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
send_messageMethod · 0.45
get_remote_endpointMethod · 0.45

Tested by

no test coverage detected