Traffic statistics (#4017)

* Network stats

* Fixed tests
This commit is contained in:
Arkadiy Paronyan
2019-11-05 12:15:59 +01:00
committed by Gavin Wood
parent 4ca6f8d1b2
commit b92674d88a
6 changed files with 283 additions and 171 deletions
@@ -222,6 +222,32 @@ pub mod generic {
ChainSpecific(Vec<u8>),
}
impl<Header, Hash, Number, Extrinsic> Message<Header, Hash, Number, Extrinsic> {
/// Message id useful for logging.
pub fn id(&self) -> &'static str {
match self {
Message::Status(_) => "Status",
Message::BlockRequest(_) => "BlockRequest",
Message::BlockResponse(_) => "BlockResponse",
Message::BlockAnnounce(_) => "BlockAnnounce",
Message::Transactions(_) => "Transactions",
Message::Consensus(_) => "Consensus",
Message::RemoteCallRequest(_) => "RemoteCallRequest",
Message::RemoteCallResponse(_) => "RemoteCallResponse",
Message::RemoteReadRequest(_) => "RemoteReadRequest",
Message::RemoteReadResponse(_) => "RemoteReadResponse",
Message::RemoteHeaderRequest(_) => "RemoteHeaderRequest",
Message::RemoteHeaderResponse(_) => "RemoteHeaderResponse",
Message::RemoteChangesRequest(_) => "RemoteChangesRequest",
Message::RemoteChangesResponse(_) => "RemoteChangesResponse",
Message::RemoteReadChildRequest(_) => "RemoteReadChildRequest",
Message::FinalityProofRequest(_) => "FinalityProofRequest",
Message::FinalityProofResponse(_) => "FinalityProofResponse",
Message::ChainSpecific(_) => "ChainSpecific",
}
}
}
/// Status sent on connection.
#[derive(Debug, PartialEq, Eq, Clone, Encode, Decode)]
pub struct Status<Hash, Number> {