From e4cf54025c3dc0902cc14422518085d4091daae0 Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Mon, 10 Feb 2020 14:52:36 +0100 Subject: [PATCH 1/2] sync: fix eth_protocol_version --- ethcore/sync/src/sync_io.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethcore/sync/src/sync_io.rs b/ethcore/sync/src/sync_io.rs index b92e0cd2960..91a1ba473d4 100644 --- a/ethcore/sync/src/sync_io.rs +++ b/ethcore/sync/src/sync_io.rs @@ -18,6 +18,7 @@ use std::sync::Arc; use std::collections::HashMap; use crate::chain::sync_packet::{PacketInfo, SyncPacket}; +use crate::ETH_PROTOCOL; use bytes::Bytes; use client_traits::BlockChainClient; @@ -142,7 +143,7 @@ impl<'s> SyncIo for NetSyncIo<'s> { } fn eth_protocol_version(&self, peer_id: PeerId) -> u8 { - self.network.protocol_version(self.network.subprotocol_name(), peer_id).unwrap_or(0) + self.network.protocol_version(ETH_PROTOCOL, peer_id).unwrap_or(0) } fn protocol_version(&self, protocol: &ProtocolId, peer_id: PeerId) -> u8 { From 8d2120bd7eaf3b764423088e7473cb5d2ee5aba4 Mon Sep 17 00:00:00 2001 From: Andronik Ordian Date: Mon, 10 Feb 2020 16:36:09 +0100 Subject: [PATCH 2/2] sync: remove eth_protocol_version altogether --- ethcore/sync/src/sync_io.rs | 7 ------- ethcore/sync/src/tests/helpers.rs | 8 ++------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/ethcore/sync/src/sync_io.rs b/ethcore/sync/src/sync_io.rs index 91a1ba473d4..f3fcfa1eec1 100644 --- a/ethcore/sync/src/sync_io.rs +++ b/ethcore/sync/src/sync_io.rs @@ -18,7 +18,6 @@ use std::sync::Arc; use std::collections::HashMap; use crate::chain::sync_packet::{PacketInfo, SyncPacket}; -use crate::ETH_PROTOCOL; use bytes::Bytes; use client_traits::BlockChainClient; @@ -55,8 +54,6 @@ pub trait SyncIo { fn peer_enode(&self, peer_id: PeerId) -> Option; /// Returns information on p2p session fn peer_session_info(&self, peer_id: PeerId) -> Option; - /// Maximum mutually supported ETH protocol version - fn eth_protocol_version(&self, peer_id: PeerId) -> u8; /// Maximum mutually supported version of a gien protocol. fn protocol_version(&self, protocol: &ProtocolId, peer_id: PeerId) -> u8; /// Returns if the chain block queue empty @@ -142,10 +139,6 @@ impl<'s> SyncIo for NetSyncIo<'s> { self.network.session_info(peer_id) } - fn eth_protocol_version(&self, peer_id: PeerId) -> u8 { - self.network.protocol_version(ETH_PROTOCOL, peer_id).unwrap_or(0) - } - fn protocol_version(&self, protocol: &ProtocolId, peer_id: PeerId) -> u8 { self.network.protocol_version(*protocol, peer_id).unwrap_or(0) } diff --git a/ethcore/sync/src/tests/helpers.rs b/ethcore/sync/src/tests/helpers.rs index 02839f6877d..4ca63671d08 100644 --- a/ethcore/sync/src/tests/helpers.rs +++ b/ethcore/sync/src/tests/helpers.rs @@ -155,12 +155,8 @@ impl<'p, C> SyncIo for TestIo<'p, C> where C: FlushingBlockChainClient, C: 'p { None } - fn eth_protocol_version(&self, _peer: PeerId) -> u8 { - ETH_PROTOCOL_VERSION_63.0 - } - - fn protocol_version(&self, protocol: &ProtocolId, peer_id: PeerId) -> u8 { - if protocol == &WARP_SYNC_PROTOCOL_ID { PAR_PROTOCOL_VERSION_4.0 } else { self.eth_protocol_version(peer_id) } + fn protocol_version(&self, protocol: &ProtocolId, _peer_id: PeerId) -> u8 { + if protocol == &WARP_SYNC_PROTOCOL_ID { PAR_PROTOCOL_VERSION_4.0 } else { ETH_PROTOCOL_VERSION_63.0 } } fn is_expired(&self) -> bool {