diff options
Diffstat (limited to 'src/transport/mod.rs')
| -rw-r--r-- | src/transport/mod.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/transport/mod.rs b/src/transport/mod.rs index f20110a..147e560 100644 --- a/src/transport/mod.rs +++ b/src/transport/mod.rs @@ -147,6 +147,10 @@ pub(crate) enum ParsedMessage { Who(IdentityProof), /// Answers a WHO. Me(IdentityProof), + /// Asks for a PONG with this nonce, over the same path (`transport::paths`). + Ping(u64), + /// Answers a PING. + Pong(u64), } /// A node's proof that it holds the key of its node ID (`identity`), sending from its @@ -270,6 +274,8 @@ pub(crate) enum MessageKind { Blob, Who, Me, + Ping, + Pong, } impl ParsedMessage { @@ -283,11 +289,13 @@ impl ParsedMessage { ParsedMessage::Blob(_) => MessageKind::Blob, ParsedMessage::Who(_) => MessageKind::Who, ParsedMessage::Me(_) => MessageKind::Me, + ParsedMessage::Ping(_) => MessageKind::Ping, + ParsedMessage::Pong(_) => MessageKind::Pong, } } /// The sender's epoch and `SyncEnvelope::epoch_seq`, as every message carries them - /// but WHO and ME (which the node never sees). + /// but WHO, ME, PING and PONG (which the node never sees). pub(crate) fn epoch_stamp(&self) -> Option<(Epoch, u32)> { match self { ParsedMessage::Hello(hello) => Some((hello.epoch, hello.epoch_seq)), @@ -297,7 +305,10 @@ impl ParsedMessage { Some((status.epoch, status.epoch_seq)) } ParsedMessage::Blob(blob) => Some((blob.epoch, blob.epoch_seq)), - ParsedMessage::Who(_) | ParsedMessage::Me(_) => None, + ParsedMessage::Who(_) + | ParsedMessage::Me(_) + | ParsedMessage::Ping(_) + | ParsedMessage::Pong(_) => None, } } } @@ -334,7 +345,7 @@ pub(crate) struct ListedPeer { } /// Where messages to a peer go now (`Transport::destination`). -#[derive(Debug, Clone, PartialEq, Eq, Serialize)] +#[derive(Debug, Clone, PartialEq, Serialize)] #[serde(rename_all = "camelCase")] pub(crate) struct Destination { /// As the identity layer keeps it: `<scheme>:<transport identity>`. @@ -344,6 +355,9 @@ pub(crate) struct Destination { pub(crate) proven: bool, /// The transport's connection to it, if the transport has connections. pub(crate) connection: Option<Connection>, + /// Every address it proved itself at, best first, as the paths layer measures them + /// (`transport::paths`). + pub(crate) paths: Vec<stats::PathInfo>, } /// How a transport with connections (libp2p) is connected to a peer. |
