Make specification of protocol in SyncRequester::send_request explicit (#10295)
* Make the specification of the protocol to which a packet_id belongs to explicit when calling "SyncRequester::send_packet". * Remove "SyncIO::send" and leave only "SyncIO::send_protocol" * Adapt tests to new code. * Strengthen tests to check if packet_id and protocol match when sending a devp2p packet.
This commit is contained in:
@@ -103,7 +103,7 @@ use fastmap::{H256FastMap, H256FastSet};
|
||||
use parking_lot::{Mutex, RwLock, RwLockWriteGuard};
|
||||
use bytes::Bytes;
|
||||
use rlp::{RlpStream, DecoderError};
|
||||
use network::{self, PeerId, PacketId};
|
||||
use network::{self, PeerId, PacketId, ProtocolId};
|
||||
use network::client_version::ClientVersion;
|
||||
use ethcore::client::{BlockChainClient, BlockStatus, BlockId, BlockChainInfo, BlockQueueInfo};
|
||||
use ethcore::snapshot::{RestorationStatus};
|
||||
@@ -112,7 +112,7 @@ use super::{WarpSync, SyncConfig};
|
||||
use block_sync::{BlockDownloader, DownloadAction};
|
||||
use rand::Rng;
|
||||
use snapshot::{Snapshot};
|
||||
use api::{EthProtocolInfo as PeerInfoDigest, WARP_SYNC_PROTOCOL_ID, PriorityTask};
|
||||
use api::{EthProtocolInfo as PeerInfoDigest, ETH_PROTOCOL, WARP_SYNC_PROTOCOL_ID, PriorityTask};
|
||||
use private_tx::PrivateTxHandler;
|
||||
use transactions_stats::{TransactionsStats, Stats as TransactionStats};
|
||||
use types::transaction::UnverifiedTransaction;
|
||||
@@ -154,7 +154,7 @@ const MAX_TRANSACTION_PACKET_SIZE: usize = 5 * 1024 * 1024;
|
||||
const SNAPSHOT_RESTORE_THRESHOLD: BlockNumber = 30000;
|
||||
const SNAPSHOT_MIN_PEERS: usize = 3;
|
||||
|
||||
const STATUS_PACKET: u8 = 0x00;
|
||||
pub const STATUS_PACKET: u8 = 0x00;
|
||||
const NEW_BLOCK_HASHES_PACKET: u8 = 0x01;
|
||||
const TRANSACTIONS_PACKET: u8 = 0x02;
|
||||
pub const GET_BLOCK_HEADERS_PACKET: u8 = 0x03;
|
||||
@@ -484,7 +484,7 @@ impl ChainSyncApi {
|
||||
for peers in sync.get_peers(&chain_info, PeerState::SameBlock).chunks(10) {
|
||||
check_deadline(deadline)?;
|
||||
for peer in peers {
|
||||
SyncPropagator::send_packet(io, *peer, NEW_BLOCK_PACKET, rlp.clone());
|
||||
SyncPropagator::send_packet(io, ETH_PROTOCOL, *peer, NEW_BLOCK_PACKET, rlp.clone());
|
||||
if let Some(ref mut peer) = sync.peers.get_mut(peer) {
|
||||
peer.latest_hash = hash;
|
||||
}
|
||||
@@ -1331,8 +1331,8 @@ impl ChainSync {
|
||||
}
|
||||
|
||||
/// Broadcast private transaction message to peers.
|
||||
pub fn propagate_private_transaction(&mut self, io: &mut SyncIo, transaction_hash: H256, packet_id: PacketId, packet: Bytes) {
|
||||
SyncPropagator::propagate_private_transaction(self, io, transaction_hash, packet_id, packet);
|
||||
pub fn propagate_private_transaction(&mut self, io: &mut SyncIo, transaction_hash: H256, protocol: ProtocolId, packet_id: PacketId, packet: Bytes) {
|
||||
SyncPropagator::propagate_private_transaction(self, io, transaction_hash, protocol, packet_id, packet);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user