Skip to content

Commit

Permalink
Rename to maintainer
Browse files Browse the repository at this point in the history
  • Loading branch information
HDauven committed Oct 13, 2023
1 parent 29f2ba0 commit 321fa45
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ The `kadcast::peer` is the entry point of the library and the only public API. I
## Message Handler
The `Message Handler` represents the core component of the library. It handles the incoming messages and replies according to the specification.

## Mantainer
## Maintainer
The `Maintainer` performs the [initial bootstrap](../bootstrapping) as well as the `k-table` [maintenance](../periodic-network-manteinance).
It keeps track of idle buckets and is in charge of triggering the routing nodes lookup.

Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use handling::MessageHandler;
pub use handling::MessageInfo;
use itertools::Itertools;
use kbucket::{BucketHeight, Tree};
use mantainer::TableMantainer;
use maintainer::TableMaintainer;
use peer::{PeerInfo, PeerNode};
use rand::prelude::IteratorRandom;
pub(crate) use rwlock::RwLock;
Expand All @@ -29,7 +29,7 @@ pub mod config;
mod encoding;
mod handling;
mod kbucket;
mod mantainer;
mod maintainer;
mod peer;
mod rwlock;
pub mod transport;
Expand Down Expand Up @@ -118,7 +118,7 @@ impl Peer {
config,
blocklist,
);
TableMantainer::start(nodes, table, outbound_channel_tx, idle_time);
TableMaintainer::start(nodes, table, outbound_channel_tx, idle_time);
task::spawn(Peer::notifier(listener_channel_rx, listener));
Ok(peer)
}
Expand Down
20 changes: 10 additions & 10 deletions src/mantainer.rs → src/maintainer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ use crate::peer::PeerInfo;
use crate::transport::MessageBeanOut;
use crate::RwLock;

pub(crate) struct TableMantainer {
pub(crate) struct TableMaintainer {
bootstrapping_nodes: Vec<String>,
ktable: RwLock<Tree<PeerInfo>>,
outbound_sender: Sender<MessageBeanOut>,
my_ip: SocketAddr,
header: Header,
}

impl TableMantainer {
impl TableMaintainer {
pub fn start(
bootstrapping_nodes: Vec<String>,
ktable: RwLock<Tree<PeerInfo>>,
Expand All @@ -35,14 +35,14 @@ impl TableMantainer {
let my_ip = *ktable.read().await.root().value().address();
let header = ktable.read().await.root().to_header();

let mantainer = Self {
let maintainer = Self {
bootstrapping_nodes,
ktable,
outbound_sender,
my_ip,
header,
};
mantainer.monitor_buckets(idle_time).await;
maintainer.monitor_buckets(idle_time).await;
});
}

Expand Down Expand Up @@ -76,7 +76,7 @@ impl TableMantainer {
/// Try to contact the bootstrappers node until no needed anymore
async fn contact_bootstrappers(&self) {
while self.need_bootstrappers().await {
info!("TableMantainer::contact_bootstrappers");
info!("TableMaintainer::contact_bootstrappers");
let bootstrapping_nodes_addr = self.bootstrapping_nodes_addr();
let binary_key = self.header.binary_id().as_binary();
let find_nodes = Message::FindNodes(self.header, *binary_key);
Expand All @@ -90,7 +90,7 @@ impl TableMantainer {
.send(message)
.await
.unwrap_or_else(|e| {
error!("Unable to send message from mantainer {e}")
error!("Unable to send message from maintainer {e}")
})
}

Expand All @@ -99,17 +99,17 @@ impl TableMantainer {
/// 2. Ping idle buckets
/// 3. Remove idles nodes from buckets
async fn monitor_buckets(&self, idle_time: Duration) {
info!("TableMantainer::monitor_buckets started");
info!("TableMaintainer::monitor_buckets started");
loop {
self.contact_bootstrappers().await;
info!("TableMantainer::monitor_buckets back to sleep");
info!("TableMaintainer::monitor_buckets back to sleep");

tokio::time::sleep(idle_time).await;

info!("TableMantainer::monitor_buckets woke up");
info!("TableMaintainer::monitor_buckets woke up");
self.ping_idle_buckets().await;

info!("TableMantainer::monitor_buckets removing idle nodes");
info!("TableMaintainer::monitor_buckets removing idle nodes");
self.ktable.write().await.remove_idle_nodes();
}
}
Expand Down

0 comments on commit 321fa45

Please sign in to comment.