Support sendheaders network message decode
This commit is contained in:
parent
084f82be21
commit
84835f244c
|
@ -99,6 +99,8 @@ pub enum NetworkMessage {
|
||||||
Block(block::Block),
|
Block(block::Block),
|
||||||
/// `headers`
|
/// `headers`
|
||||||
Headers(Vec<block::BlockHeader>),
|
Headers(Vec<block::BlockHeader>),
|
||||||
|
/// `sendheaders`
|
||||||
|
SendHeaders,
|
||||||
/// `getaddr`
|
/// `getaddr`
|
||||||
GetAddr,
|
GetAddr,
|
||||||
// TODO: checkorder,
|
// TODO: checkorder,
|
||||||
|
@ -142,6 +144,7 @@ impl RawNetworkMessage {
|
||||||
NetworkMessage::Tx(_) => "tx",
|
NetworkMessage::Tx(_) => "tx",
|
||||||
NetworkMessage::Block(_) => "block",
|
NetworkMessage::Block(_) => "block",
|
||||||
NetworkMessage::Headers(_) => "headers",
|
NetworkMessage::Headers(_) => "headers",
|
||||||
|
NetworkMessage::SendHeaders => "sendheaders",
|
||||||
NetworkMessage::GetAddr => "getaddr",
|
NetworkMessage::GetAddr => "getaddr",
|
||||||
NetworkMessage::Ping(_) => "ping",
|
NetworkMessage::Ping(_) => "ping",
|
||||||
NetworkMessage::Pong(_) => "pong",
|
NetworkMessage::Pong(_) => "pong",
|
||||||
|
@ -194,6 +197,7 @@ impl<S: Encoder> Encodable<S> for RawNetworkMessage {
|
||||||
NetworkMessage::CFCheckpt(ref dat) => serialize(dat),
|
NetworkMessage::CFCheckpt(ref dat) => serialize(dat),
|
||||||
NetworkMessage::Alert(ref dat) => serialize(dat),
|
NetworkMessage::Alert(ref dat) => serialize(dat),
|
||||||
NetworkMessage::Verack
|
NetworkMessage::Verack
|
||||||
|
| NetworkMessage::SendHeaders
|
||||||
| NetworkMessage::MemPool
|
| NetworkMessage::MemPool
|
||||||
| NetworkMessage::GetAddr => vec![],
|
| NetworkMessage::GetAddr => vec![],
|
||||||
}).consensus_encode(s)
|
}).consensus_encode(s)
|
||||||
|
@ -243,6 +247,7 @@ impl<D: Decoder> Decodable<D> for RawNetworkMessage {
|
||||||
"headers" =>
|
"headers" =>
|
||||||
NetworkMessage::Headers(<HeaderDeserializationWrapper as Decodable<Cursor<Vec<u8>>>>
|
NetworkMessage::Headers(<HeaderDeserializationWrapper as Decodable<Cursor<Vec<u8>>>>
|
||||||
::consensus_decode(&mut mem_d)?.0),
|
::consensus_decode(&mut mem_d)?.0),
|
||||||
|
"sendheaders" => NetworkMessage::SendHeaders,
|
||||||
"getaddr" => NetworkMessage::GetAddr,
|
"getaddr" => NetworkMessage::GetAddr,
|
||||||
"ping" => NetworkMessage::Ping(Decodable::consensus_decode(&mut mem_d)?),
|
"ping" => NetworkMessage::Ping(Decodable::consensus_decode(&mut mem_d)?),
|
||||||
"pong" => NetworkMessage::Pong(Decodable::consensus_decode(&mut mem_d)?),
|
"pong" => NetworkMessage::Pong(Decodable::consensus_decode(&mut mem_d)?),
|
||||||
|
|
Loading…
Reference in New Issue