From 3f528a8e669b9434395eba7cb1fbdb3859dfa4e2 Mon Sep 17 00:00:00 2001 From: hashmap Date: Fri, 29 Nov 2019 13:04:55 +0100 Subject: [PATCH] Captute "type" byte for unknow message type (#3146) Found it useful for debugging --- p2p/src/conn.rs | 6 +++++- p2p/src/msg.rs | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/p2p/src/conn.rs b/p2p/src/conn.rs index 4bfe5bc6b..1402d1640 100644 --- a/p2p/src/conn.rs +++ b/p2p/src/conn.rs @@ -293,7 +293,11 @@ where try_break!(conn_handle.send(resp_msg)); } } - Some(MsgHeaderWrapper::Unknown(msg_len)) => { + Some(MsgHeaderWrapper::Unknown(msg_len, type_byte)) => { + debug!( + "Received unknown message header, type {:?}, len {}.", + type_byte, msg_len + ); // Increase received bytes counter reader_tracker.inc_received(MsgHeader::LEN as u64 + msg_len); diff --git a/p2p/src/msg.rs b/p2p/src/msg.rs index a6bace09a..1bd82db48 100644 --- a/p2p/src/msg.rs +++ b/p2p/src/msg.rs @@ -205,7 +205,7 @@ pub fn read_message( Err(Error::BadMessage) } } - MsgHeaderWrapper::Unknown(msg_len) => { + MsgHeaderWrapper::Unknown(msg_len, _) => { read_discard(msg_len, stream)?; Err(Error::BadMessage) } @@ -248,7 +248,7 @@ pub enum MsgHeaderWrapper { /// A "known" msg type with deserialized msg header. Known(MsgHeader), /// An unknown msg type with corresponding msg size in bytes. - Unknown(u64), + Unknown(u64, u8), } /// Header of any protocol message, used to identify incoming messages. @@ -331,7 +331,7 @@ impl Readable for MsgHeaderWrapper { return Err(ser::Error::TooLargeReadErr); } - Ok(MsgHeaderWrapper::Unknown(msg_len)) + Ok(MsgHeaderWrapper::Unknown(msg_len, t)) } } }