Optimize Reject message
This commit is contained in:
parent
c30d6d12ab
commit
5c84e9671f
|
@ -61,9 +61,8 @@ impl Encodable for CommandString {
|
||||||
&self,
|
&self,
|
||||||
s: S,
|
s: S,
|
||||||
) -> Result<usize, encode::Error> {
|
) -> Result<usize, encode::Error> {
|
||||||
let &CommandString(ref inner_str) = self;
|
|
||||||
let mut rawbytes = [0u8; 12];
|
let mut rawbytes = [0u8; 12];
|
||||||
let strbytes = inner_str.as_bytes();
|
let strbytes = self.0.as_bytes();
|
||||||
if strbytes.len() > 12 {
|
if strbytes.len() > 12 {
|
||||||
panic!("Command string longer than 12 bytes");
|
panic!("Command string longer than 12 bytes");
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,14 @@
|
||||||
//! capabilities
|
//! capabilities
|
||||||
//!
|
//!
|
||||||
|
|
||||||
|
use std::io;
|
||||||
|
use std::borrow::Cow;
|
||||||
|
|
||||||
use network::address::Address;
|
use network::address::Address;
|
||||||
use network::constants::{self, ServiceFlags};
|
use network::constants::{self, ServiceFlags};
|
||||||
use consensus::{Encodable, Decodable, ReadExt};
|
use consensus::{Encodable, Decodable, ReadExt};
|
||||||
use consensus::encode;
|
use consensus::encode;
|
||||||
use std::io;
|
use network::message::CommandString;
|
||||||
use network::message_network::RejectReason::{MALFORMED, INVALID, OBSOLETE, DUPLICATE, NONSTANDARD, DUST, CHECKPOINT, FEE};
|
use network::message_network::RejectReason::{MALFORMED, INVALID, OBSOLETE, DUPLICATE, NONSTANDARD, DUST, CHECKPOINT, FEE};
|
||||||
use hashes::sha256d;
|
use hashes::sha256d;
|
||||||
|
|
||||||
|
@ -131,11 +134,11 @@ impl Decodable for RejectReason {
|
||||||
#[derive(PartialEq, Eq, Clone, Debug)]
|
#[derive(PartialEq, Eq, Clone, Debug)]
|
||||||
pub struct Reject {
|
pub struct Reject {
|
||||||
/// message type rejected
|
/// message type rejected
|
||||||
pub message: String,
|
pub message: CommandString,
|
||||||
/// reason of rejection as code
|
/// reason of rejection as code
|
||||||
pub ccode: RejectReason,
|
pub ccode: RejectReason,
|
||||||
/// reason of rejectection
|
/// reason of rejectection
|
||||||
pub reason: String,
|
pub reason: Cow<'static, str>,
|
||||||
/// reference to rejected item
|
/// reference to rejected item
|
||||||
pub hash: sha256d::Hash
|
pub hash: sha256d::Hash
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue