diff --git a/llarp/nodedb.cpp b/llarp/nodedb.cpp index d8e16e49d..d285b7900 100644 --- a/llarp/nodedb.cpp +++ b/llarp/nodedb.cpp @@ -181,7 +181,7 @@ namespace llarp } void - NodeDB::update_rcs() + NodeDB::fetch_rcs() { std::vector needed; diff --git a/llarp/nodedb.hpp b/llarp/nodedb.hpp index a411df4f1..c1d49b3ea 100644 --- a/llarp/nodedb.hpp +++ b/llarp/nodedb.hpp @@ -124,7 +124,7 @@ namespace llarp ingest_router_ids(RouterID source, std::vector ids); void - update_rcs(); + fetch_rcs(); void fetch_router_ids(); diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 1ac96bb7d..7a23a3748 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -835,11 +835,21 @@ namespace llarp next_rc_gossip = now_timepoint + RouterContact::STALE_AGE - random_delta; } - // (client-only) periodically fetch updated RCs - if (now_timepoint - last_rc_fetch > RC_UPDATE_INTERVAL) + if (not is_snode) { - node_db()->update_rcs(); - last_rc_fetch = now_timepoint; + // (client-only) periodically fetch updated RCs + if (now_timepoint - last_rc_fetch > RC_UPDATE_INTERVAL) + { + node_db()->fetch_rcs(); + last_rc_fetch = now_timepoint; + } + + // (client-only) periodically fetch updated RouterID list + if (now_timepoint - last_routerid_fetch > ROUTERID_UPDATE_INTERVAL) + { + node_db()->fetch_router_ids(); + last_routerid_fetch = now_timepoint; + } } // remove RCs for nodes that are no longer allowed by network policy diff --git a/llarp/router/router.hpp b/llarp/router/router.hpp index cf2e60f7f..cdd6da7ab 100644 --- a/llarp/router/router.hpp +++ b/llarp/router/router.hpp @@ -58,6 +58,7 @@ namespace llarp (INTROSET_RELAY_REDUNDANCY * INTROSET_REQS_PER_RELAY); static const std::chrono::seconds RC_UPDATE_INTERVAL = 5min; + static const std::chrono::seconds ROUTERID_UPDATE_INTERVAL = 1h; struct Contacts; @@ -133,6 +134,8 @@ namespace llarp std::chrono::system_clock::time_point last_rc_fetch{ std::chrono::system_clock::time_point::min()}; + std::chrono::system_clock::time_point last_routerid_fetch{ + std::chrono::system_clock::time_point::min()}; // should we be sending padded messages every interval? bool send_padding = false;