Correct internal par protocol nomenclature
This commit is contained in:
parent
a75ba3620c
commit
2ab8c72ce3
@ -62,7 +62,7 @@ use types::{pruning_info::PruningInfo, transaction::UnverifiedTransaction, Block
|
|||||||
use super::light_sync::SyncInfo;
|
use super::light_sync::SyncInfo;
|
||||||
|
|
||||||
/// Parity sync protocol
|
/// Parity sync protocol
|
||||||
pub const WARP_SYNC_PROTOCOL_ID: ProtocolId = *b"par";
|
pub const PAR_PROTOCOL: ProtocolId = *b"par";
|
||||||
/// Ethereum sync protocol
|
/// Ethereum sync protocol
|
||||||
pub const ETH_PROTOCOL: ProtocolId = *b"eth";
|
pub const ETH_PROTOCOL: ProtocolId = *b"eth";
|
||||||
/// Ethereum light protocol
|
/// Ethereum light protocol
|
||||||
@ -449,7 +449,7 @@ struct SyncProtocolHandler {
|
|||||||
|
|
||||||
impl NetworkProtocolHandler for SyncProtocolHandler {
|
impl NetworkProtocolHandler for SyncProtocolHandler {
|
||||||
fn initialize(&self, io: &dyn NetworkContext) {
|
fn initialize(&self, io: &dyn NetworkContext) {
|
||||||
if io.subprotocol_name() != WARP_SYNC_PROTOCOL_ID {
|
if io.subprotocol_name() != PAR_PROTOCOL {
|
||||||
io.register_timer(PEERS_TIMER, Duration::from_millis(700))
|
io.register_timer(PEERS_TIMER, Duration::from_millis(700))
|
||||||
.expect("Error registering peers timer");
|
.expect("Error registering peers timer");
|
||||||
io.register_timer(MAINTAIN_SYNC_TIMER, Duration::from_millis(1100))
|
io.register_timer(MAINTAIN_SYNC_TIMER, Duration::from_millis(1100))
|
||||||
@ -476,11 +476,8 @@ impl NetworkProtocolHandler for SyncProtocolHandler {
|
|||||||
fn connected(&self, io: &dyn NetworkContext, peer: &PeerId) {
|
fn connected(&self, io: &dyn NetworkContext, peer: &PeerId) {
|
||||||
trace_time!("sync::connected");
|
trace_time!("sync::connected");
|
||||||
// If warp protocol is supported only allow warp handshake
|
// If warp protocol is supported only allow warp handshake
|
||||||
let warp_protocol = io
|
let warp_protocol = io.protocol_version(PAR_PROTOCOL, *peer).unwrap_or(0) != 0;
|
||||||
.protocol_version(WARP_SYNC_PROTOCOL_ID, *peer)
|
let warp_context = io.subprotocol_name() == PAR_PROTOCOL;
|
||||||
.unwrap_or(0)
|
|
||||||
!= 0;
|
|
||||||
let warp_context = io.subprotocol_name() == WARP_SYNC_PROTOCOL_ID;
|
|
||||||
if warp_protocol == warp_context {
|
if warp_protocol == warp_context {
|
||||||
self.sync.write().on_peer_connected(
|
self.sync.write().on_peer_connected(
|
||||||
&mut NetSyncIo::new(io, &*self.chain, &*self.snapshot_service, &self.overlay),
|
&mut NetSyncIo::new(io, &*self.chain, &*self.snapshot_service, &self.overlay),
|
||||||
@ -491,7 +488,7 @@ impl NetworkProtocolHandler for SyncProtocolHandler {
|
|||||||
|
|
||||||
fn disconnected(&self, io: &dyn NetworkContext, peer: &PeerId) {
|
fn disconnected(&self, io: &dyn NetworkContext, peer: &PeerId) {
|
||||||
trace_time!("sync::disconnected");
|
trace_time!("sync::disconnected");
|
||||||
if io.subprotocol_name() != WARP_SYNC_PROTOCOL_ID {
|
if io.subprotocol_name() != PAR_PROTOCOL {
|
||||||
self.sync.write().on_peer_aborting(
|
self.sync.write().on_peer_aborting(
|
||||||
&mut NetSyncIo::new(io, &*self.chain, &*self.snapshot_service, &self.overlay),
|
&mut NetSyncIo::new(io, &*self.chain, &*self.snapshot_service, &self.overlay),
|
||||||
*peer,
|
*peer,
|
||||||
@ -598,7 +595,7 @@ impl ChainNotify for EthSync {
|
|||||||
self.network
|
self.network
|
||||||
.register_protocol(
|
.register_protocol(
|
||||||
self.eth_handler.clone(),
|
self.eth_handler.clone(),
|
||||||
WARP_SYNC_PROTOCOL_ID,
|
PAR_PROTOCOL,
|
||||||
&[
|
&[
|
||||||
PAR_PROTOCOL_VERSION_1,
|
PAR_PROTOCOL_VERSION_1,
|
||||||
PAR_PROTOCOL_VERSION_2,
|
PAR_PROTOCOL_VERSION_2,
|
||||||
@ -625,7 +622,7 @@ impl ChainNotify for EthSync {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn broadcast(&self, message_type: ChainMessageType) {
|
fn broadcast(&self, message_type: ChainMessageType) {
|
||||||
self.network.with_context(WARP_SYNC_PROTOCOL_ID, |context| {
|
self.network.with_context(PAR_PROTOCOL, |context| {
|
||||||
let mut sync_io = NetSyncIo::new(
|
let mut sync_io = NetSyncIo::new(
|
||||||
context,
|
context,
|
||||||
&*self.eth_handler.chain,
|
&*self.eth_handler.chain,
|
||||||
@ -827,7 +824,7 @@ impl NetworkConfiguration {
|
|||||||
max_peers: self.max_peers,
|
max_peers: self.max_peers,
|
||||||
min_peers: self.min_peers,
|
min_peers: self.min_peers,
|
||||||
max_handshakes: self.max_pending_peers,
|
max_handshakes: self.max_pending_peers,
|
||||||
reserved_protocols: hash_map![WARP_SYNC_PROTOCOL_ID => self.snapshot_peers],
|
reserved_protocols: hash_map![PAR_PROTOCOL => self.snapshot_peers],
|
||||||
reserved_nodes: self.reserved_nodes,
|
reserved_nodes: self.reserved_nodes,
|
||||||
ip_filter: self.ip_filter,
|
ip_filter: self.ip_filter,
|
||||||
non_reserved_mode: if self.allow_non_reserved {
|
non_reserved_mode: if self.allow_non_reserved {
|
||||||
@ -859,10 +856,7 @@ impl From<BasicNetworkConfiguration> for NetworkConfiguration {
|
|||||||
max_peers: other.max_peers,
|
max_peers: other.max_peers,
|
||||||
min_peers: other.min_peers,
|
min_peers: other.min_peers,
|
||||||
max_pending_peers: other.max_handshakes,
|
max_pending_peers: other.max_handshakes,
|
||||||
snapshot_peers: *other
|
snapshot_peers: *other.reserved_protocols.get(&PAR_PROTOCOL).unwrap_or(&0),
|
||||||
.reserved_protocols
|
|
||||||
.get(&WARP_SYNC_PROTOCOL_ID)
|
|
||||||
.unwrap_or(&0),
|
|
||||||
reserved_nodes: other.reserved_nodes,
|
reserved_nodes: other.reserved_nodes,
|
||||||
ip_filter: other.ip_filter,
|
ip_filter: other.ip_filter,
|
||||||
allow_non_reserved: match other.non_reserved_mode {
|
allow_non_reserved: match other.non_reserved_mode {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use api::WARP_SYNC_PROTOCOL_ID;
|
use api::PAR_PROTOCOL;
|
||||||
use block_sync::{BlockDownloaderImportError as DownloaderImportError, DownloadAction};
|
use block_sync::{BlockDownloaderImportError as DownloaderImportError, DownloadAction};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use enum_primitive::FromPrimitive;
|
use enum_primitive::FromPrimitive;
|
||||||
@ -659,7 +659,7 @@ impl SyncHandler {
|
|||||||
) -> Result<(), DownloaderImportError> {
|
) -> Result<(), DownloaderImportError> {
|
||||||
sync.handshaking_peers.remove(&peer_id);
|
sync.handshaking_peers.remove(&peer_id);
|
||||||
let protocol_version: u8 = r.val_at(0)?;
|
let protocol_version: u8 = r.val_at(0)?;
|
||||||
let warp_protocol_version = io.protocol_version(&WARP_SYNC_PROTOCOL_ID, peer_id);
|
let warp_protocol_version = io.protocol_version(&PAR_PROTOCOL, peer_id);
|
||||||
let warp_protocol = warp_protocol_version != 0;
|
let warp_protocol = warp_protocol_version != 0;
|
||||||
let private_tx_protocol = warp_protocol_version >= PAR_PROTOCOL_VERSION_3.0;
|
let private_tx_protocol = warp_protocol_version >= PAR_PROTOCOL_VERSION_3.0;
|
||||||
let peer = PeerInfo {
|
let peer = PeerInfo {
|
||||||
|
@ -94,7 +94,7 @@ mod supplier;
|
|||||||
pub mod sync_packet;
|
pub mod sync_packet;
|
||||||
|
|
||||||
use super::{SyncConfig, WarpSync};
|
use super::{SyncConfig, WarpSync};
|
||||||
use api::{EthProtocolInfo as PeerInfoDigest, PriorityTask, WARP_SYNC_PROTOCOL_ID};
|
use api::{EthProtocolInfo as PeerInfoDigest, PriorityTask, PAR_PROTOCOL};
|
||||||
use block_sync::{BlockDownloader, DownloadAction};
|
use block_sync::{BlockDownloader, DownloadAction};
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use ethcore::{
|
use ethcore::{
|
||||||
@ -1206,7 +1206,7 @@ impl ChainSync {
|
|||||||
|
|
||||||
/// Send Status message
|
/// Send Status message
|
||||||
fn send_status(&mut self, io: &mut dyn SyncIo, peer: PeerId) -> Result<(), network::Error> {
|
fn send_status(&mut self, io: &mut dyn SyncIo, peer: PeerId) -> Result<(), network::Error> {
|
||||||
let warp_protocol_version = io.protocol_version(&WARP_SYNC_PROTOCOL_ID, peer);
|
let warp_protocol_version = io.protocol_version(&PAR_PROTOCOL, peer);
|
||||||
let warp_protocol = warp_protocol_version != 0;
|
let warp_protocol = warp_protocol_version != 0;
|
||||||
let private_tx_protocol = warp_protocol_version >= PAR_PROTOCOL_VERSION_3.0;
|
let private_tx_protocol = warp_protocol_version >= PAR_PROTOCOL_VERSION_3.0;
|
||||||
let protocol = if warp_protocol {
|
let protocol = if warp_protocol {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#![allow(unused_doc_comments)]
|
#![allow(unused_doc_comments)]
|
||||||
|
|
||||||
use api::{ETH_PROTOCOL, WARP_SYNC_PROTOCOL_ID};
|
use api::{ETH_PROTOCOL, PAR_PROTOCOL};
|
||||||
use network::{PacketId, ProtocolId};
|
use network::{PacketId, ProtocolId};
|
||||||
|
|
||||||
// An enum that defines all known packet ids in the context of
|
// An enum that defines all known packet ids in the context of
|
||||||
@ -93,7 +93,7 @@ impl PacketInfo for SyncPacket {
|
|||||||
| SnapshotDataPacket
|
| SnapshotDataPacket
|
||||||
| ConsensusDataPacket
|
| ConsensusDataPacket
|
||||||
| PrivateTransactionPacket
|
| PrivateTransactionPacket
|
||||||
| SignedPrivateTransactionPacket => WARP_SYNC_PROTOCOL_ID,
|
| SignedPrivateTransactionPacket => PAR_PROTOCOL,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +132,6 @@ mod tests {
|
|||||||
#[test]
|
#[test]
|
||||||
fn when_consensus_data_packet_then_id_and_protocol_match() {
|
fn when_consensus_data_packet_then_id_and_protocol_match() {
|
||||||
assert_eq!(ConsensusDataPacket.id(), ConsensusDataPacket as PacketId);
|
assert_eq!(ConsensusDataPacket.id(), ConsensusDataPacket as PacketId);
|
||||||
assert_eq!(ConsensusDataPacket.protocol(), WARP_SYNC_PROTOCOL_ID);
|
assert_eq!(ConsensusDataPacket.protocol(), PAR_PROTOCOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
// along with Parity Ethereum. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
use api::WARP_SYNC_PROTOCOL_ID;
|
use api::PAR_PROTOCOL;
|
||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use chain::{
|
use chain::{
|
||||||
sync_packet::{
|
sync_packet::{
|
||||||
@ -176,7 +176,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn protocol_version(&self, protocol: &ProtocolId, peer_id: PeerId) -> u8 {
|
fn protocol_version(&self, protocol: &ProtocolId, peer_id: PeerId) -> u8 {
|
||||||
if protocol == &WARP_SYNC_PROTOCOL_ID {
|
if protocol == &PAR_PROTOCOL {
|
||||||
PAR_PROTOCOL_VERSION_3.0
|
PAR_PROTOCOL_VERSION_3.0
|
||||||
} else {
|
} else {
|
||||||
self.eth_protocol_version(peer_id)
|
self.eth_protocol_version(peer_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user