Add keep-alive timeout to coordinator

The Heartbeat was meant to serve for this, yet no Heartbeats are fired when we
don't have active tributaries.

libp2p does offer an explicit KeepAlive protocol, yet it's not recommended in
prod. While this likely has the same pit falls as LibP2p's KeepAlive protocol,
it's at least tailored to our timing.
This commit is contained in:
Luke Parker
2023-08-21 02:36:03 -04:00
parent 45ea805620
commit dc88b29b92
2 changed files with 44 additions and 12 deletions

View File

@@ -53,8 +53,8 @@ mod substrate;
#[cfg(test)]
pub mod tests;
// This is a static to satisfy lifetime expectations
lazy_static::lazy_static! {
// This is a static to satisfy lifetime expectations
static ref NEW_TRIBUTARIES: RwLock<VecDeque<TributarySpec>> = RwLock::new(VecDeque::new());
}
@@ -271,6 +271,8 @@ pub async fn handle_p2p<D: Db, P: P2p>(
loop {
let mut msg = p2p.receive().await;
match msg.kind {
P2pMessageKind::KeepAlive => {}
P2pMessageKind::Tributary(genesis) => {
let tributaries = tributaries.read().await;
let Some(tributary) = tributaries.get(&genesis) else {