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
6use nym_credentials_interface::TicketType;
7
8use crate::ticketbooks::AvailableTicketbooks;
9
10#[derive(Debug, Clone)]
11pub struct BandwidthControllerConfig {
12 // How often the controller proactively checks whether any ticket type needs restocking.
13 pub topup_interval: Duration,
14 // Threshold to determine if a ticket is soon expired
15 pub soon_expiry_threshold: Duration,
16
17 // If we go below this threshold, we should request more tickets
18 pub nb_ticket_restock: u64,
19
20 // If we go below this threshold, we should request more tickets
21 pub min_nb_ticket_needed: u64,
22
23 // Ticket types the controller proactively restocks: the periodic sweep, the post-spend top-up,
24 // and the restock triggered when a credential fetcher is installed. Defaults to every
25 // non-mixnet-exit type. Set to an empty vec to disable proactive restocking entirely — a
26 // credential fetcher can still be installed to serve on-demand / explicit fetches without the
27 // controller ever depositing on its own.
28 pub managed_ticket_types: Vec<TicketType>,
29}
30
31impl Default for BandwidthControllerConfig {
32 fn default() -> Self {
33 Self {
34 topup_interval: Duration::from_secs(3 * 3600), // 3 hours,
35 soon_expiry_threshold: Duration::from_secs(12 * 3600), // 12 hours,
36 nb_ticket_restock: 20,
37 min_nb_ticket_needed: 5,
38 managed_ticket_types: AvailableTicketbooks::ticketbook_types(),
39 }
40 }
41}