From 90a2c379779699d3e63ff92ae8faed9382b372fd Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 4 Nov 2016 17:35:31 +0100 Subject: [PATCH] handle unknown packet --- sync/src/light/mod.rs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/sync/src/light/mod.rs b/sync/src/light/mod.rs index d7d1a84f7..a4aa0dcf7 100644 --- a/sync/src/light/mod.rs +++ b/sync/src/light/mod.rs @@ -148,22 +148,22 @@ impl Chain { let mut stream = RlpStream::new_list(6); stream .begin_list(2) - .append("protocolVersion") + .append(&"protocolVersion") .append(&PROTOCOL_VERSION) .begin_list(2) - .append("networkId") + .append(&"networkId") .append(&(self.mainnet as u8)) .begin_list(2) - .append("headTd") + .append(&"headTd") .append(&chain_info.total_difficulty) .begin_list(2) - .append("headHash") + .append(&"headHash") .append(&chain_info.best_block_hash) .begin_list(2) - .append("headNum") + .append(&"headNum") .append(&chain_info.best_block_number) .begin_list(2) - .append("genesisHash") + .append(&"genesisHash") .append(&self.genesis_hash); io.send(peer, packet::STATUS, stream.out()) @@ -315,6 +315,11 @@ impl NetworkProtocolHandler for Chain { packet::GET_TRANSACTION_PROOFS => self.get_transaction_proofs(peer, io, rlp), packet::TRANSACTION_PROOFS => self.transaction_proofs(peer, io, rlp), + + other => { + debug!(target: "les", "Disconnecting peer {} on unexpected packet {}", peer, other); + io.disconnect_peer(*peer); + } } } @@ -330,7 +335,6 @@ impl NetworkProtocolHandler for Chain { match timer { TIMEOUT => { // broadcast transactions to peers. - // update buffer flow. } _ => warn!(target: "les", "received timeout on unknown token {}", timer), }