Optimize Reject message

This commit is contained in:
Steven Roose 2019-12-03 22:39:04 +00:00
parent c30d6d12ab
commit 5c84e9671f
No known key found for this signature in database
GPG Key ID: 2F2A88D7F8D68E87
2 changed files with 7 additions and 5 deletions

View File

@ -61,9 +61,8 @@ impl Encodable for CommandString {
&self,
s: S,
) -> Result<usize, encode::Error> {
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");
}

View File

@ -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
}