mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 12:19:24 +00:00
Send a heartbeat message when a Tributary falls behind
This commit is contained in:
@@ -12,6 +12,7 @@ pub use tributary::P2p as TributaryP2p;
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug)]
|
||||
pub enum P2pMessageKind {
|
||||
Tributary([u8; 32]),
|
||||
Heartbeat([u8; 32]),
|
||||
}
|
||||
|
||||
impl P2pMessageKind {
|
||||
@@ -22,6 +23,11 @@ impl P2pMessageKind {
|
||||
res.extend(genesis);
|
||||
res
|
||||
}
|
||||
P2pMessageKind::Heartbeat(genesis) => {
|
||||
let mut res = vec![1];
|
||||
res.extend(genesis);
|
||||
res
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,6 +40,11 @@ impl P2pMessageKind {
|
||||
reader.read_exact(&mut genesis).ok()?;
|
||||
P2pMessageKind::Tributary(genesis)
|
||||
}),
|
||||
1 => Some({
|
||||
let mut genesis = [0; 32];
|
||||
reader.read_exact(&mut genesis).ok()?;
|
||||
P2pMessageKind::Heartbeat(genesis)
|
||||
}),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user