Skip to main content

run_bucket_refresh

Function run_bucket_refresh 

Source
pub async fn run_bucket_refresh(
    endpoint: Endpoint,
    self_id: PublicKey,
    routing: Arc<Mutex<RoutingTable>>,
    stop_rx: Receiver<()>,
    interval: Duration,
    refresh_clock: Arc<AtomicU64>,
    metrics: Arc<Metrics>,
)
Expand description

Long-running task: every BUCKET_REFRESH_TICK runs a FindNode(random_id_in_bucket) against each non-empty bucket’s most-recently-seen peer in parallel. Exits on stop_rx.

refresh_clock is stamped with the wall-clock microseconds at which each refresh pass completes, so the admin_v1_status health view (issue #741) can report the network-wide “last refreshed” time. Since a pass touches all non-empty buckets at once, a single timestamp is the honest representation — there is no per-bucket refresh time. It starts at 0 (“never refreshed”) and is updated every tick regardless of whether any bucket was populated, so it tracks “the refresh task is alive and ran at T” rather than “a bucket received fresh entries”.

Each pass also counts its failed bucket refreshes into decdn_dht_bucket_refresh_failures_total and publishes the table’s size as decdn_dht_routing_table_size.