diff --git a/zebra-network/src/message.rs b/zebra-network/src/message.rs index 7509a5ab5..617076cb2 100644 --- a/zebra-network/src/message.rs +++ b/zebra-network/src/message.rs @@ -93,13 +93,16 @@ pub enum Message { /// A `ping` message. /// /// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#ping) - Ping(Nonce), + Ping( + /// A nonce unique to this [`Ping`] message. + Nonce, + ), /// A `pong` message. /// /// [Bitcoin reference](https://en.bitcoin.it/wiki/Protocol_documentation#pong) Pong( - /// The nonce from the `Ping` message this was in response to. + /// The nonce from the [`Ping`] message this was in response to. Nonce, ), @@ -450,6 +453,13 @@ impl Message { writer.write_u32::(start_height.0)?; writer.write_u8(*relay as u8)?; } + Verack => { /* Empty payload -- no-op */ } + Ping(nonce) => { + writer.write_u64::(nonce.0)?; + } + Pong(nonce) => { + writer.write_u64::(nonce.0)?; + } _ => unimplemented!(), } Ok(()) @@ -487,21 +497,21 @@ fn try_read_verack( mut _reader: R, _version: Version, ) -> Result { - unimplemented!() + Ok(Message::Verack) } fn try_read_ping( - mut _reader: R, + mut reader: R, _version: Version, ) -> Result { - unimplemented!() + Ok(Message::Ping(Nonce(reader.read_u64::()?))) } fn try_read_pong( - mut _reader: R, + mut reader: R, _version: Version, ) -> Result { - unimplemented!() + Ok(Message::Pong(Nonce(reader.read_u64::()?))) } fn try_read_reject(