nym_network_defaults/
ecash.rs

1// Copyright 2024 - Nym Technologies SA <contact@nymtech.net>
2// SPDX-License-Identifier: Apache-2.0
3
4/// Specifies the maximum validity of the issued ticketbooks.
5pub const TICKETBOOK_VALIDITY_DAYS: u32 = 7;
6
7/// Specifies the number of tickets in each issued ticketbook.
8pub const TICKETBOOK_SIZE: u64 = 50;
9
10/// Specifies the minimum request size each signer must support
11pub const MINIMUM_TICKETBOOK_DATA_REQUEST_SIZE: usize = 50;
12
13/// This type is defined mostly for the purposes of having constants (like sizes) associated with given variants
14/// It's not meant to be serialised or have any fancy traits defined on it (in this crate)
15#[derive(Copy, Clone, Debug, PartialEq)]
16#[repr(u8)]
17pub enum TicketTypeRepr {
18    V1MixnetEntry = 0,
19    V1MixnetExit = 1,
20    V1WireguardEntry = 2,
21    V1WireguardExit = 3,
22}
23
24impl TicketTypeRepr {
25    pub const WIREGUARD_ENTRY_TICKET_SIZE: u64 = 500 * 1000 * 1000; // 500 MB
26    pub const WIREGUARD_EXIT_TICKET_SIZE: u64 = 500 * 1000 * 1000; // 500 MB
27    pub const MIXNET_ENTRY_TICKET_SIZE: u64 = 200 * 1000 * 1000; // 200 MB
28    pub const MIXNET_EXIT_TICKET_SIZE: u64 = 100 * 1000 * 1000; // 100 MB
29
30    /// How much bandwidth (in bytes) one ticket can grant
31    pub const fn bandwidth_value(&self) -> u64 {
32        match self {
33            TicketTypeRepr::V1MixnetEntry => Self::MIXNET_ENTRY_TICKET_SIZE,
34            TicketTypeRepr::V1MixnetExit => Self::MIXNET_EXIT_TICKET_SIZE,
35            TicketTypeRepr::V1WireguardEntry => Self::WIREGUARD_ENTRY_TICKET_SIZE,
36            TicketTypeRepr::V1WireguardExit => Self::WIREGUARD_EXIT_TICKET_SIZE,
37        }
38    }
39}