diff --git a/src/network/message.rs b/src/network/message.rs index da252c57..cb4674be 100644 --- a/src/network/message.rs +++ b/src/network/message.rs @@ -61,9 +61,8 @@ impl Encodable for CommandString { &self, s: S, ) -> Result { - let &CommandString(ref inner_str) = self; let mut rawbytes = [0u8; 12]; - let strbytes = inner_str.as_bytes(); + let strbytes = self.0.as_bytes(); if strbytes.len() > 12 { panic!("Command string longer than 12 bytes"); } diff --git a/src/network/message_network.rs b/src/network/message_network.rs index 45056507..4eb22f98 100644 --- a/src/network/message_network.rs +++ b/src/network/message_network.rs @@ -18,11 +18,14 @@ //! capabilities //! +use std::io; +use std::borrow::Cow; + use network::address::Address; use network::constants::{self, ServiceFlags}; use consensus::{Encodable, Decodable, ReadExt}; use consensus::encode; -use std::io; +use network::message::CommandString; use network::message_network::RejectReason::{MALFORMED, INVALID, OBSOLETE, DUPLICATE, NONSTANDARD, DUST, CHECKPOINT, FEE}; use hashes::sha256d; @@ -131,11 +134,11 @@ impl Decodable for RejectReason { #[derive(PartialEq, Eq, Clone, Debug)] pub struct Reject { /// message type rejected - pub message: String, + pub message: CommandString, /// reason of rejection as code pub ccode: RejectReason, /// reason of rejectection - pub reason: String, + pub reason: Cow<'static, str>, /// reference to rejected item pub hash: sha256d::Hash }