Also have getter for CommandString
This commit is contained in:
parent
e2eed78964
commit
e37fdb7319
|
@ -156,7 +156,7 @@ pub enum NetworkMessage {
|
||||||
|
|
||||||
impl NetworkMessage {
|
impl NetworkMessage {
|
||||||
/// Return the message command. This is useful for debug outputs.
|
/// Return the message command. This is useful for debug outputs.
|
||||||
pub fn command(&self) -> &'static str {
|
pub fn cmd(&self) -> &'static str {
|
||||||
match *self {
|
match *self {
|
||||||
NetworkMessage::Version(_) => "version",
|
NetworkMessage::Version(_) => "version",
|
||||||
NetworkMessage::Verack => "verack",
|
NetworkMessage::Verack => "verack",
|
||||||
|
@ -184,11 +184,21 @@ impl NetworkMessage {
|
||||||
NetworkMessage::Reject(_) => "reject",
|
NetworkMessage::Reject(_) => "reject",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Return the CommandString for the message command.
|
||||||
|
pub fn command(&self) -> CommandString {
|
||||||
|
self.cmd().into()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RawNetworkMessage {
|
impl RawNetworkMessage {
|
||||||
/// Return the message command. This is useful for debug outputs.
|
/// Return the message command. This is useful for debug outputs.
|
||||||
pub fn command(&self) -> &'static str {
|
pub fn cmd(&self) -> &'static str {
|
||||||
|
self.payload.cmd()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the CommandString for the message command.
|
||||||
|
pub fn command(&self) -> CommandString {
|
||||||
self.payload.command()
|
self.payload.command()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,7 +228,7 @@ impl Encodable for RawNetworkMessage {
|
||||||
) -> Result<usize, encode::Error> {
|
) -> Result<usize, encode::Error> {
|
||||||
let mut len = 0;
|
let mut len = 0;
|
||||||
len += self.magic.consensus_encode(&mut s)?;
|
len += self.magic.consensus_encode(&mut s)?;
|
||||||
len += CommandString(self.command().into()).consensus_encode(&mut s)?;
|
len += self.command().consensus_encode(&mut s)?;
|
||||||
len += CheckedData(match self.payload {
|
len += CheckedData(match self.payload {
|
||||||
NetworkMessage::Version(ref dat) => serialize(dat),
|
NetworkMessage::Version(ref dat) => serialize(dat),
|
||||||
NetworkMessage::Addr(ref dat) => serialize(dat),
|
NetworkMessage::Addr(ref dat) => serialize(dat),
|
||||||
|
|
Loading…
Reference in New Issue