Skip to main content

nym_bandwidth_controller/
config.rs

1// Copyright 2026 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4use std::time::Duration;
5
6#[derive(Debug, Clone, Copy)]
7pub struct BandwidthControllerConfig {
8    // How often the controller proactively checks whether any ticket type needs restocking.
9    pub topup_interval: Duration,
10    // Threshold to determine if a ticket is soon expired
11    pub soon_expiry_threshold: Duration,
12
13    // If we go below this threshold, we should request more tickets
14    pub nb_ticket_restock: u64,
15
16    // If we go below this threshold, we should request more tickets
17    pub min_nb_ticket_needed: u64,
18}
19
20impl Default for BandwidthControllerConfig {
21    fn default() -> Self {
22        Self {
23            topup_interval: Duration::from_secs(3 * 3600), // 3 hours,
24            soon_expiry_threshold: Duration::from_secs(12 * 3600), // 12 hours,
25            nb_ticket_restock: 20,
26            min_nb_ticket_needed: 5,
27        }
28    }
29}