diff --git a/src/network/message.rs b/src/network/message.rs index 9dff5af0..69ec7864 100644 --- a/src/network/message.rs +++ b/src/network/message.rs @@ -114,10 +114,12 @@ pub enum NetworkMessage { /// `ping` Ping(u64), /// `pong` - Pong(u64) + Pong(u64), // TODO: reject, // TODO: bloom filtering // TODO: alert + /// `alert` + Alert(Vec) } impl RawNetworkMessage { @@ -138,6 +140,7 @@ impl RawNetworkMessage { NetworkMessage::GetAddr => "getaddr", NetworkMessage::Ping(_) => "ping", NetworkMessage::Pong(_) => "pong", + NetworkMessage::Alert(_) => "alert", }.to_owned() } } @@ -162,6 +165,7 @@ impl ConsensusEncodable for RawNetworkMessage { NetworkMessage::GetAddr => Ok(vec![]), NetworkMessage::Ping(ref dat) => serialize(dat), NetworkMessage::Pong(ref dat) => serialize(dat), + NetworkMessage::Alert(ref dat) => serialize(dat) }.unwrap()).consensus_encode(s)); Ok(()) } @@ -192,6 +196,7 @@ impl> ConsensusDecodable for RawNetworkMe "ping" => NetworkMessage::Ping(try!(propagate_err("ping".to_owned(), ConsensusDecodable::consensus_decode(&mut mem_d)))), "pong" => NetworkMessage::Pong(try!(propagate_err("pong".to_owned(), ConsensusDecodable::consensus_decode(&mut mem_d)))), "tx" => NetworkMessage::Tx(try!(propagate_err("tx".to_owned(), ConsensusDecodable::consensus_decode(&mut mem_d)))), + "alert" => NetworkMessage::Alert(try!(propagate_err("alert".to_owned(), ConsensusDecodable::consensus_decode(&mut mem_d)))), cmd => return Err(d.error(format!("unrecognized network command `{}`", cmd))) }; Ok(RawNetworkMessage {