Skip to content

Commit

Permalink
Merge branch 'main' into add-address-override
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-aranha-cw authored Jun 3, 2024
2 parents ec8e0c6 + 7340525 commit 062b635
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/eth/consensus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl Consensus {
let consensus = Arc::new(consensus);

let _ = Self::discover_peers(Arc::clone(&consensus)).await; //TODO refactor this method to also receive addresses from the environment
Self::initialize_periodic_peer_discovery(Arc::clone(&consensus));
Self::initialize_append_entries_channel(Arc::clone(&consensus), Arc::clone(&receiver));
Self::initialize_server(Arc::clone(&consensus));

Expand Down Expand Up @@ -153,6 +154,17 @@ impl Consensus {
})
}

fn initialize_periodic_peer_discovery(consensus: Arc<Consensus>) {
named_spawn("consensus::peer_discovery", async move {
let mut interval = tokio::time::interval(Duration::from_secs(30));
loop {
interval.tick().await;
tracing::info!("Starting periodic peer discovery...");
Self::discover_peers(Arc::clone(&consensus)).await;
}
});
}

fn initialize_append_entries_channel(consensus: Arc<Consensus>, receiver: Arc<Mutex<mpsc::Receiver<Block>>>) {
named_spawn("consensus::sender", async move {
let peers = consensus.peers.read().await;
Expand Down

0 comments on commit 062b635

Please sign in to comment.