kadmium/core/
routing_table.rs

1use std::collections::{HashMap, HashSet};
2
3use crate::core::id::Id;
4
5/// The core routing table data structure.
6#[derive(Debug, Clone)]
7pub(crate) struct RoutingTable<T, U> {
8    // The node's local identifier.
9    pub(crate) local_id: Id,
10    // The maximum number of identifiers that can be contained in a bucket.
11    pub(crate) max_bucket_size: u8,
12    // The number of addresses to share when responding to a FIND_K_NODES query.
13    pub(crate) k: u8,
14    // The buckets constructed for broadcast purposes.
15    pub(crate) buckets: HashMap<u32, HashSet<Id>>,
16    // Maps identifiers to peer meta data (connected and disconnected).
17    pub(crate) peer_list: HashMap<Id, U>,
18    // Maps connection identifiers to peer identifiers (connected only).
19    pub(crate) id_list: HashMap<T, Id>,
20}