diff options
author | hozan23 <hozan23@karyontech.net> | 2024-07-15 13:16:01 +0200 |
---|---|---|
committer | hozan23 <hozan23@karyontech.net> | 2024-07-15 13:16:01 +0200 |
commit | e15d3e6fd20b3f87abaad7ddec1c88b0e66419f9 (patch) | |
tree | 7976f6993e4f6b3646f5bd6954189346d5ffd330 /p2p/src/message.rs | |
parent | 6c65232d741229635151671708556b9af7ef75ac (diff) |
p2p: Major refactoring of the handshake protocol
Introduce a new protocol InitProtocol which can be used as the core protocol
for initializing a connection with a peer.
Move the handshake logic from the PeerPool module to the protocols directory and
build a handshake protocol that implements InitProtocol trait.
Diffstat (limited to 'p2p/src/message.rs')
-rw-r--r-- | p2p/src/message.rs | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/p2p/src/message.rs b/p2p/src/message.rs index 6498ef7..5bf0853 100644 --- a/p2p/src/message.rs +++ b/p2p/src/message.rs @@ -110,7 +110,9 @@ pub struct PeerMsg { /// PeersMsg a list of `PeerMsg`. #[derive(Decode, Encode, Debug)] -pub struct PeersMsg(pub Vec<PeerMsg>); +pub struct PeersMsg { + pub peers: Vec<PeerMsg>, +} impl From<Entry> for PeerMsg { fn from(entry: Entry) -> PeerMsg { @@ -133,19 +135,3 @@ impl From<PeerMsg> for Entry { } } } - -macro_rules! get_msg_payload { - ($a:ident, $b:ident) => { - if let NetMsgCmd::$a = $b.header.command { - $b.payload - } else { - return Err(Error::InvalidMsg(format!( - "Expected {:?} msg found {:?} msg", - stringify!($a), - $b.header.command - ))); - } - }; -} - -pub(super) use get_msg_payload; |