Fix warnings: dyn

This commit is contained in:
adria0
2020-07-29 10:36:15 +02:00
committed by Artem Vorotnikov
parent 4adb44155d
commit 1700873f48
198 changed files with 1180 additions and 1072 deletions

View File

@@ -218,7 +218,7 @@ impl From<light_net::Status> for PipProtocolInfo {
/// Only works when IPC is disabled.
pub struct AttachedProtocol {
/// The protocol handler in question.
pub handler: Arc<NetworkProtocolHandler + Send + Sync>,
pub handler: Arc<dyn NetworkProtocolHandler + Send + Sync>,
/// 3-character ID for the protocol.
pub protocol_id: ProtocolId,
/// Supported versions and their packet counts.
@@ -273,13 +273,13 @@ pub struct Params {
/// Configuration.
pub config: SyncConfig,
/// Blockchain client.
pub chain: Arc<BlockChainClient>,
pub chain: Arc<dyn BlockChainClient>,
/// Snapshot service.
pub snapshot_service: Arc<SnapshotService>,
pub snapshot_service: Arc<dyn SnapshotService>,
/// Private tx service.
pub private_tx_handler: Option<Arc<PrivateTxHandler>>,
pub private_tx_handler: Option<Arc<dyn PrivateTxHandler>>,
/// Light data provider.
pub provider: Arc<::light::Provider>,
pub provider: Arc<dyn crate::light::Provider>,
/// Network layer configuration.
pub network_config: NetworkConfiguration,
/// Other protocols to attach.
@@ -308,7 +308,7 @@ fn light_params(
network_id: u64,
median_peers: f64,
pruning_info: PruningInfo,
sample_store: Option<Box<SampleStore>>,
sample_store: Option<Box<dyn SampleStore>>,
) -> LightParams {
let mut light_params = LightParams {
network_id: network_id,
@@ -330,7 +330,7 @@ impl EthSync {
/// Creates and register protocol with the network service
pub fn new(
params: Params,
connection_filter: Option<Arc<ConnectionFilter>>,
connection_filter: Option<Arc<dyn ConnectionFilter>>,
) -> Result<Arc<EthSync>, Error> {
let pruning_info = params.chain.pruning_info();
let light_proto = match params.config.serve_light {
@@ -464,9 +464,9 @@ pub(crate) const PRIORITY_TIMER_INTERVAL: Duration = Duration::from_millis(250);
struct SyncProtocolHandler {
/// Shared blockchain client.
chain: Arc<BlockChainClient>,
chain: Arc<dyn BlockChainClient>,
/// Shared snapshot service.
snapshot_service: Arc<SnapshotService>,
snapshot_service: Arc<dyn SnapshotService>,
/// Sync strategy
sync: ChainSyncApi,
/// Chain overlay used to cache data such as fork block.
@@ -474,7 +474,7 @@ struct SyncProtocolHandler {
}
impl NetworkProtocolHandler for SyncProtocolHandler {
fn initialize(&self, io: &NetworkContext) {
fn initialize(&self, io: &dyn NetworkContext) {
if io.subprotocol_name() != WARP_SYNC_PROTOCOL_ID {
io.register_timer(PEERS_TIMER, Duration::from_millis(700))
.expect("Error registering peers timer");
@@ -490,7 +490,7 @@ impl NetworkProtocolHandler for SyncProtocolHandler {
}
}
fn read(&self, io: &NetworkContext, peer: &PeerId, packet_id: u8, data: &[u8]) {
fn read(&self, io: &dyn NetworkContext, peer: &PeerId, packet_id: u8, data: &[u8]) {
self.sync.dispatch_packet(
&mut NetSyncIo::new(io, &*self.chain, &*self.snapshot_service, &self.overlay),
*peer,
@@ -499,7 +499,7 @@ impl NetworkProtocolHandler for SyncProtocolHandler {
);
}
fn connected(&self, io: &NetworkContext, peer: &PeerId) {
fn connected(&self, io: &dyn NetworkContext, peer: &PeerId) {
trace_time!("sync::connected");
// If warp protocol is supported only allow warp handshake
let warp_protocol = io
@@ -515,7 +515,7 @@ impl NetworkProtocolHandler for SyncProtocolHandler {
}
}
fn disconnected(&self, io: &NetworkContext, peer: &PeerId) {
fn disconnected(&self, io: &dyn NetworkContext, peer: &PeerId) {
trace_time!("sync::disconnected");
if io.subprotocol_name() != WARP_SYNC_PROTOCOL_ID {
self.sync.write().on_peer_aborting(
@@ -525,7 +525,7 @@ impl NetworkProtocolHandler for SyncProtocolHandler {
}
}
fn timeout(&self, io: &NetworkContext, timer: TimerToken) {
fn timeout(&self, io: &dyn NetworkContext, timer: TimerToken) {
trace_time!("sync::timeout");
let mut io = NetSyncIo::new(io, &*self.chain, &*self.snapshot_service, &self.overlay);
match timer {
@@ -697,12 +697,12 @@ impl ChainNotify for EthSync {
/// PIP event handler.
/// Simply queues transactions from light client peers.
struct TxRelay(Arc<BlockChainClient>);
struct TxRelay(Arc<dyn BlockChainClient>);
impl LightHandler for TxRelay {
fn on_transactions(
&self,
ctx: &EventContext,
ctx: &dyn EventContext,
relay: &[::types::transaction::UnverifiedTransaction],
) {
trace!(target: "pip", "Relaying {} transactions from peer {}", relay.len(), ctx.peer());
@@ -730,7 +730,7 @@ pub trait ManageNetwork: Send + Sync {
/// Returns the minimum and maximum peers.
fn num_peers_range(&self) -> RangeInclusive<u32>;
/// Get network context for protocol.
fn with_proto_context(&self, proto: ProtocolId, f: &mut FnMut(&NetworkContext));
fn with_proto_context(&self, proto: ProtocolId, f: &mut dyn FnMut(&dyn NetworkContext));
}
impl ManageNetwork for EthSync {
@@ -782,7 +782,7 @@ impl ManageNetwork for EthSync {
self.network.num_peers_range()
}
fn with_proto_context(&self, proto: ProtocolId, f: &mut FnMut(&NetworkContext)) {
fn with_proto_context(&self, proto: ProtocolId, f: &mut dyn FnMut(&dyn NetworkContext)) {
self.network.with_context_eval(proto, f);
}
}
@@ -964,7 +964,7 @@ pub trait LightNetworkDispatcher {
/// Execute a closure with a protocol context.
fn with_context<F, T>(&self, f: F) -> Option<T>
where
F: FnOnce(&::light::net::BasicContext) -> T;
F: FnOnce(&dyn crate::light::net::BasicContext) -> T;
}
/// Configuration for the light sync.
@@ -978,7 +978,7 @@ pub struct LightSyncParams<L> {
/// Subprotocol name.
pub subprotocol_name: [u8; 3],
/// Other handlers to attach.
pub handlers: Vec<Arc<LightHandler>>,
pub handlers: Vec<Arc<dyn LightHandler>>,
/// Other subprotocols to run.
pub attached_protos: Vec<AttachedProtocol>,
}
@@ -986,7 +986,7 @@ pub struct LightSyncParams<L> {
/// Service for light synchronization.
pub struct LightSync {
proto: Arc<LightProtocol>,
sync: Arc<SyncInfo + Sync + Send>,
sync: Arc<dyn SyncInfo + Sync + Send>,
attached_protos: Vec<AttachedProtocol>,
network: NetworkService,
subprotocol_name: [u8; 3],
@@ -1040,7 +1040,7 @@ impl LightSync {
}
impl ::std::ops::Deref for LightSync {
type Target = ::light_sync::SyncInfo;
type Target = dyn crate::light_sync::SyncInfo;
fn deref(&self) -> &Self::Target {
&*self.sync
@@ -1050,7 +1050,7 @@ impl ::std::ops::Deref for LightSync {
impl LightNetworkDispatcher for LightSync {
fn with_context<F, T>(&self, f: F) -> Option<T>
where
F: FnOnce(&::light::net::BasicContext) -> T,
F: FnOnce(&dyn crate::light::net::BasicContext) -> T,
{
self.network
.with_context_eval(self.subprotocol_name, move |ctx| {
@@ -1119,7 +1119,7 @@ impl ManageNetwork for LightSync {
self.network.num_peers_range()
}
fn with_proto_context(&self, proto: ProtocolId, f: &mut FnMut(&NetworkContext)) {
fn with_proto_context(&self, proto: ProtocolId, f: &mut dyn FnMut(&dyn NetworkContext)) {
self.network.with_context_eval(proto, f);
}
}

View File

@@ -231,7 +231,7 @@ impl BlockDownloader {
/// Add new block headers.
pub fn import_headers(
&mut self,
io: &mut SyncIo,
io: &mut dyn SyncIo,
r: &Rlp,
expected_hash: H256,
) -> Result<DownloadAction, BlockDownloaderImportError> {
@@ -463,7 +463,7 @@ impl BlockDownloader {
Ok(())
}
fn start_sync_round(&mut self, io: &mut SyncIo) {
fn start_sync_round(&mut self, io: &mut dyn SyncIo) {
self.state = State::ChainHead;
trace_sync!(
self,
@@ -541,7 +541,7 @@ impl BlockDownloader {
pub fn request_blocks(
&mut self,
peer_id: PeerId,
io: &mut SyncIo,
io: &mut dyn SyncIo,
num_active_peers: usize,
) -> Option<BlockRequest> {
match self.state {
@@ -610,7 +610,11 @@ impl BlockDownloader {
/// Checks if there are blocks fully downloaded that can be imported into the blockchain and does the import.
/// Returns DownloadAction::Reset if it is imported all the the blocks it can and all downloading peers should be reset
pub fn collect_blocks(&mut self, io: &mut SyncIo, allow_out_of_order: bool) -> DownloadAction {
pub fn collect_blocks(
&mut self,
io: &mut dyn SyncIo,
allow_out_of_order: bool,
) -> DownloadAction {
let mut download_action = DownloadAction::None;
let mut imported = HashSet::new();
let blocks = self.blocks.drain();
@@ -748,7 +752,7 @@ mod tests {
fn import_headers(
headers: &[BlockHeader],
downloader: &mut BlockDownloader,
io: &mut SyncIo,
io: &mut dyn SyncIo,
) -> Result<DownloadAction, BlockDownloaderImportError> {
let mut stream = RlpStream::new();
stream.append_list(headers);
@@ -761,7 +765,7 @@ mod tests {
fn import_headers_ok(
headers: &[BlockHeader],
downloader: &mut BlockDownloader,
io: &mut SyncIo,
io: &mut dyn SyncIo,
) {
let res = import_headers(headers, downloader, io);
assert!(res.is_ok());

View File

@@ -619,7 +619,7 @@ mod test {
client.add_blocks(100, EachBlockWith::Nothing);
let hashes = (0..100)
.map(|i| {
(&client as &BlockChainClient)
(&client as &dyn BlockChainClient)
.block_hash(BlockId::Number(i))
.unwrap()
})
@@ -639,7 +639,7 @@ mod test {
client.add_blocks(nblocks, EachBlockWith::Nothing);
let blocks: Vec<_> = (0..nblocks)
.map(|i| {
(&client as &BlockChainClient)
(&client as &dyn BlockChainClient)
.block(BlockId::Number(i as BlockNumber))
.unwrap()
.into_inner()
@@ -719,7 +719,7 @@ mod test {
client.add_blocks(nblocks, EachBlockWith::Nothing);
let blocks: Vec<_> = (0..nblocks)
.map(|i| {
(&client as &BlockChainClient)
(&client as &dyn BlockChainClient)
.block(BlockId::Number(i as BlockNumber))
.unwrap()
.into_inner()
@@ -755,7 +755,7 @@ mod test {
client.add_blocks(nblocks, EachBlockWith::Nothing);
let blocks: Vec<_> = (0..nblocks)
.map(|i| {
(&client as &BlockChainClient)
(&client as &dyn BlockChainClient)
.block(BlockId::Number(i as BlockNumber))
.unwrap()
.into_inner()

View File

@@ -54,7 +54,7 @@ impl SyncHandler {
/// Handle incoming packet from peer
pub fn on_packet(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer: PeerId,
packet_id: u8,
data: &[u8],
@@ -102,13 +102,13 @@ impl SyncHandler {
}
/// Called when peer sends us new consensus packet
pub fn on_consensus_packet(io: &mut SyncIo, peer_id: PeerId, r: &Rlp) {
pub fn on_consensus_packet(io: &mut dyn SyncIo, peer_id: PeerId, r: &Rlp) {
trace!(target: "sync", "Received consensus packet from {:?}", peer_id);
io.chain().queue_consensus_message(r.as_raw().to_vec());
}
/// Called by peer when it is disconnecting
pub fn on_peer_aborting(sync: &mut ChainSync, io: &mut SyncIo, peer_id: PeerId) {
pub fn on_peer_aborting(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId) {
trace!(target: "sync", "== Disconnecting {}: {}", peer_id, io.peer_version(peer_id));
sync.handshaking_peers.remove(&peer_id);
if sync.peers.contains_key(&peer_id) {
@@ -139,7 +139,7 @@ impl SyncHandler {
}
/// Called when a new peer is connected
pub fn on_peer_connected(sync: &mut ChainSync, io: &mut SyncIo, peer: PeerId) {
pub fn on_peer_connected(sync: &mut ChainSync, io: &mut dyn SyncIo, peer: PeerId) {
trace!(target: "sync", "== Connected {}: {}", peer, io.peer_version(peer));
if let Err(e) = sync.send_status(io, peer) {
debug!(target:"sync", "Error sending status request: {:?}", e);
@@ -152,7 +152,7 @@ impl SyncHandler {
/// Called by peer once it has new block bodies
pub fn on_peer_new_block(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -221,7 +221,7 @@ impl SyncHandler {
/// Handles `NewHashes` packet. Initiates headers download for any unknown hashes.
pub fn on_peer_new_hashes(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -305,7 +305,7 @@ impl SyncHandler {
/// Called by peer once it has new block bodies
fn on_peer_block_bodies(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -360,7 +360,7 @@ impl SyncHandler {
fn on_peer_fork_header(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -404,7 +404,7 @@ impl SyncHandler {
/// Called by peer once it has new block headers during sync
fn on_peer_block_headers(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -484,7 +484,7 @@ impl SyncHandler {
/// Called by peer once it has new block receipts
fn on_peer_block_receipts(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -539,7 +539,7 @@ impl SyncHandler {
/// Called when snapshot manifest is downloaded from a peer.
fn on_snapshot_manifest(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -580,7 +580,7 @@ impl SyncHandler {
/// Called when snapshot data is downloaded from a peer.
fn on_snapshot_data(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -653,7 +653,7 @@ impl SyncHandler {
/// Called by peer to report status
fn on_peer_status(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -768,7 +768,7 @@ impl SyncHandler {
/// Called when peer sends us new transactions
pub fn on_peer_transactions(
sync: &ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), PacketDecodeError> {
@@ -799,7 +799,7 @@ impl SyncHandler {
/// Called when peer sends us signed private transaction packet
fn on_signed_private_transaction(
sync: &mut ChainSync,
_io: &mut SyncIo,
_io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {
@@ -832,7 +832,7 @@ impl SyncHandler {
/// Called when peer sends us new private transaction packet
fn on_private_transaction(
sync: &mut ChainSync,
_io: &mut SyncIo,
_io: &mut dyn SyncIo,
peer_id: PeerId,
r: &Rlp,
) -> Result<(), DownloaderImportError> {

View File

@@ -392,8 +392,8 @@ impl ChainSyncApi {
/// Creates new `ChainSyncApi`
pub fn new(
config: SyncConfig,
chain: &BlockChainClient,
private_tx_handler: Option<Arc<PrivateTxHandler>>,
chain: &dyn BlockChainClient,
private_tx_handler: Option<Arc<dyn PrivateTxHandler>>,
priority_tasks: mpsc::Receiver<PriorityTask>,
) -> Self {
ChainSyncApi {
@@ -429,7 +429,7 @@ impl ChainSyncApi {
}
/// Dispatch incoming requests and responses
pub fn dispatch_packet(&self, io: &mut SyncIo, peer: PeerId, packet_id: u8, data: &[u8]) {
pub fn dispatch_packet(&self, io: &mut dyn SyncIo, peer: PeerId, packet_id: u8, data: &[u8]) {
SyncSupplier::dispatch_packet(&self.sync, io, peer, packet_id, data)
}
@@ -439,7 +439,7 @@ impl ChainSyncApi {
///
/// NOTE This method should only handle stuff that can be canceled and would reach other peers
/// by other means.
pub fn process_priority_queue(&self, io: &mut SyncIo) {
pub fn process_priority_queue(&self, io: &mut dyn SyncIo) {
fn check_deadline(deadline: Instant) -> Option<Duration> {
let now = Instant::now();
if now > deadline {
@@ -516,7 +516,11 @@ impl ChainSyncApi {
// Static methods
impl ChainSync {
/// creates rlp to send for the tree defined by 'from' and 'to' hashes
fn create_new_hashes_rlp(chain: &BlockChainClient, from: &H256, to: &H256) -> Option<Bytes> {
fn create_new_hashes_rlp(
chain: &dyn BlockChainClient,
from: &H256,
to: &H256,
) -> Option<Bytes> {
match chain.tree_route(from, to) {
Some(route) => {
let uncles = chain.find_uncles(from).unwrap_or_else(Vec::new);
@@ -551,7 +555,7 @@ impl ChainSync {
}
/// creates latest block rlp for the given client
fn create_latest_block_rlp(chain: &BlockChainClient) -> Bytes {
fn create_latest_block_rlp(chain: &dyn BlockChainClient) -> Bytes {
Self::create_block_rlp(
&chain
.block(BlockId::Hash(chain.chain_info().best_block_hash))
@@ -562,7 +566,7 @@ impl ChainSync {
}
/// creates given hash block rlp for the given client
fn create_new_block_rlp(chain: &BlockChainClient, hash: &H256) -> Bytes {
fn create_new_block_rlp(chain: &dyn BlockChainClient, hash: &H256) -> Bytes {
Self::create_block_rlp(
&chain
.block(BlockId::Hash(hash.clone()))
@@ -585,7 +589,7 @@ impl ChainSync {
peers
}
fn get_init_state(warp_sync: WarpSync, chain: &BlockChainClient) -> SyncState {
fn get_init_state(warp_sync: WarpSync, chain: &dyn BlockChainClient) -> SyncState {
let best_block = chain.chain_info().best_block_number;
match warp_sync {
WarpSync::Enabled => SyncState::WaitingPeers,
@@ -638,7 +642,7 @@ pub struct ChainSync {
/// Enable ancient block downloading
download_old_blocks: bool,
/// Shared private tx service.
private_tx_handler: Option<Arc<PrivateTxHandler>>,
private_tx_handler: Option<Arc<dyn PrivateTxHandler>>,
/// Enable warp sync.
warp_sync: WarpSync,
}
@@ -647,8 +651,8 @@ impl ChainSync {
/// Create a new instance of syncing strategy.
pub fn new(
config: SyncConfig,
chain: &BlockChainClient,
private_tx_handler: Option<Arc<PrivateTxHandler>>,
chain: &dyn BlockChainClient,
private_tx_handler: Option<Arc<dyn PrivateTxHandler>>,
) -> Self {
let chain_info = chain.chain_info();
let best_block = chain.chain_info().best_block_number;
@@ -744,14 +748,14 @@ impl ChainSync {
}
/// Abort all sync activity
pub fn abort(&mut self, io: &mut SyncIo) {
pub fn abort(&mut self, io: &mut dyn SyncIo) {
self.reset_and_continue(io);
self.peers.clear();
}
/// Reset sync. Clear all downloaded data but keep the queue.
/// Set sync state to the given state or to the initial state if `None` is provided.
fn reset(&mut self, io: &mut SyncIo, state: Option<SyncState>) {
fn reset(&mut self, io: &mut dyn SyncIo, state: Option<SyncState>) {
self.new_blocks.reset();
let chain_info = io.chain().chain_info();
for (_, ref mut p) in &mut self.peers {
@@ -770,7 +774,7 @@ impl ChainSync {
}
/// Restart sync
pub fn reset_and_continue(&mut self, io: &mut SyncIo) {
pub fn reset_and_continue(&mut self, io: &mut dyn SyncIo) {
trace!(target: "sync", "Restarting");
if self.state == SyncState::SnapshotData {
debug!(target:"sync", "Aborting snapshot restore");
@@ -783,12 +787,12 @@ impl ChainSync {
/// Remove peer from active peer set. Peer will be reactivated on the next sync
/// round.
fn deactivate_peer(&mut self, _io: &mut SyncIo, peer_id: PeerId) {
fn deactivate_peer(&mut self, _io: &mut dyn SyncIo, peer_id: PeerId) {
trace!(target: "sync", "Deactivating peer {}", peer_id);
self.active_peers.remove(&peer_id);
}
fn maybe_start_snapshot_sync(&mut self, io: &mut SyncIo) {
fn maybe_start_snapshot_sync(&mut self, io: &mut dyn SyncIo) {
if !self.warp_sync.is_enabled() || io.snapshot_service().supported_versions().is_none() {
trace!(target: "sync", "Skipping warp sync. Disabled or not supported.");
return;
@@ -868,7 +872,7 @@ impl ChainSync {
}
}
fn start_snapshot_sync(&mut self, io: &mut SyncIo, peers: &[PeerId]) {
fn start_snapshot_sync(&mut self, io: &mut dyn SyncIo, peers: &[PeerId]) {
if !self.snapshot.have_manifest() {
for p in peers {
if self
@@ -888,13 +892,13 @@ impl ChainSync {
}
/// Restart sync disregarding the block queue status. May end up re-downloading up to QUEUE_SIZE blocks
pub fn restart(&mut self, io: &mut SyncIo) {
pub fn restart(&mut self, io: &mut dyn SyncIo) {
self.update_targets(io.chain());
self.reset_and_continue(io);
}
/// Update sync after the blockchain has been changed externally.
pub fn update_targets(&mut self, chain: &BlockChainClient) {
pub fn update_targets(&mut self, chain: &dyn BlockChainClient) {
// Do not assume that the block queue/chain still has our last_imported_block
let chain = chain.chain_info();
self.new_blocks = BlockDownloader::new(
@@ -923,7 +927,7 @@ impl ChainSync {
}
/// Resume downloading
pub fn continue_sync(&mut self, io: &mut SyncIo) {
pub fn continue_sync(&mut self, io: &mut dyn SyncIo) {
if self.state == SyncState::Waiting {
trace!(target: "sync", "Waiting for the block queue");
} else if self.state == SyncState::SnapshotWaiting {
@@ -974,7 +978,7 @@ impl ChainSync {
}
/// Called after all blocks have been downloaded
fn complete_sync(&mut self, io: &mut SyncIo) {
fn complete_sync(&mut self, io: &mut dyn SyncIo) {
trace!(target: "sync", "Sync complete");
self.reset(io, Some(SyncState::Idle));
}
@@ -986,7 +990,7 @@ impl ChainSync {
}
/// Find something to do for a peer. Called for a new peer or when a peer is done with its task.
fn sync_peer(&mut self, io: &mut SyncIo, peer_id: PeerId, force: bool) {
fn sync_peer(&mut self, io: &mut dyn SyncIo, peer_id: PeerId, force: bool) {
if !self.active_peers.contains(&peer_id) {
trace!(target: "sync", "Skipping deactivated peer {}", peer_id);
return;
@@ -1136,7 +1140,7 @@ impl ChainSync {
}
/// Checks if there are blocks fully downloaded that can be imported into the blockchain and does the import.
fn collect_blocks(&mut self, io: &mut SyncIo, block_set: BlockSet) {
fn collect_blocks(&mut self, io: &mut dyn SyncIo, block_set: BlockSet) {
match block_set {
BlockSet::NewBlocks => {
if self
@@ -1201,7 +1205,7 @@ impl ChainSync {
}
/// Send Status message
fn send_status(&mut self, io: &mut 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 = warp_protocol_version != 0;
let private_tx_protocol = warp_protocol_version >= PAR_PROTOCOL_VERSION_3.0;
@@ -1233,7 +1237,7 @@ impl ChainSync {
io.respond(StatusPacket.id(), packet.out())
}
pub fn maintain_peers(&mut self, io: &mut SyncIo) {
pub fn maintain_peers(&mut self, io: &mut dyn SyncIo) {
let tick = Instant::now();
let mut aborting = Vec::new();
for (peer_id, peer) in &self.peers {
@@ -1267,7 +1271,7 @@ impl ChainSync {
}
}
fn check_resume(&mut self, io: &mut SyncIo) {
fn check_resume(&mut self, io: &mut dyn SyncIo) {
match self.state {
SyncState::Waiting if !io.chain().queue_info().is_full() => {
self.state = SyncState::Blocks;
@@ -1369,7 +1373,7 @@ impl ChainSync {
}
/// Maintain other peers. Send out any new blocks and transactions
pub fn maintain_sync(&mut self, io: &mut SyncIo) {
pub fn maintain_sync(&mut self, io: &mut dyn SyncIo) {
self.maybe_start_snapshot_sync(io);
self.check_resume(io);
}
@@ -1377,7 +1381,7 @@ impl ChainSync {
/// called when block is imported to chain - propagates the blocks and updates transactions sent to peers
pub fn chain_new_blocks(
&mut self,
io: &mut SyncIo,
io: &mut dyn SyncIo,
_imported: &[H256],
invalid: &[H256],
enacted: &[H256],
@@ -1409,22 +1413,22 @@ impl ChainSync {
}
}
pub fn on_packet(&mut self, io: &mut SyncIo, peer: PeerId, packet_id: u8, data: &[u8]) {
pub fn on_packet(&mut self, io: &mut dyn SyncIo, peer: PeerId, packet_id: u8, data: &[u8]) {
SyncHandler::on_packet(self, io, peer, packet_id, data);
}
/// Called by peer when it is disconnecting
pub fn on_peer_aborting(&mut self, io: &mut SyncIo, peer: PeerId) {
pub fn on_peer_aborting(&mut self, io: &mut dyn SyncIo, peer: PeerId) {
SyncHandler::on_peer_aborting(self, io, peer);
}
/// Called when a new peer is connected
pub fn on_peer_connected(&mut self, io: &mut SyncIo, peer: PeerId) {
pub fn on_peer_connected(&mut self, io: &mut dyn SyncIo, peer: PeerId) {
SyncHandler::on_peer_connected(self, io, peer);
}
/// propagates new transactions to all peers
pub fn propagate_new_transactions(&mut self, io: &mut SyncIo) {
pub fn propagate_new_transactions(&mut self, io: &mut dyn SyncIo) {
let deadline = Instant::now() + Duration::from_millis(500);
SyncPropagator::propagate_new_transactions(self, io, || {
if deadline > Instant::now() {
@@ -1437,14 +1441,14 @@ impl ChainSync {
}
/// Broadcast consensus message to peers.
pub fn propagate_consensus_packet(&mut self, io: &mut SyncIo, packet: Bytes) {
pub fn propagate_consensus_packet(&mut self, io: &mut dyn SyncIo, packet: Bytes) {
SyncPropagator::propagate_consensus_packet(self, io, packet);
}
/// Broadcast private transaction message to peers.
pub fn propagate_private_transaction(
&mut self,
io: &mut SyncIo,
io: &mut dyn SyncIo,
transaction_hash: H256,
packet_id: SyncPacket,
packet: Bytes,
@@ -1558,7 +1562,10 @@ pub mod tests {
assert!(!sync_status(SyncState::Idle).is_syncing(queue_info(0, 0)));
}
pub fn dummy_sync_with_peer(peer_latest_hash: H256, client: &BlockChainClient) -> ChainSync {
pub fn dummy_sync_with_peer(
peer_latest_hash: H256,
client: &dyn BlockChainClient,
) -> ChainSync {
let mut sync = ChainSync::new(SyncConfig::default(), client, None);
insert_dummy_peer(&mut sync, 0, peer_latest_hash);
sync

View File

@@ -43,13 +43,13 @@ impl SyncPropagator {
pub fn propagate_blocks(
sync: &mut ChainSync,
chain_info: &BlockChainInfo,
io: &mut SyncIo,
io: &mut dyn SyncIo,
blocks: &[H256],
peers: &[PeerId],
) -> usize {
trace!(target: "sync", "Sending NewBlocks to {:?}", peers);
let sent = peers.len();
let mut send_packet = |io: &mut SyncIo, rlp: Bytes| {
let mut send_packet = |io: &mut dyn SyncIo, rlp: Bytes| {
for peer_id in peers {
SyncPropagator::send_packet(io, *peer_id, NewBlockPacket, rlp.clone());
@@ -76,7 +76,7 @@ impl SyncPropagator {
pub fn propagate_new_hashes(
sync: &mut ChainSync,
chain_info: &BlockChainInfo,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peers: &[PeerId],
) -> usize {
trace!(target: "sync", "Sending NewHashes to {:?}", peers);
@@ -101,7 +101,7 @@ impl SyncPropagator {
/// propagates new transactions to all peers
pub fn propagate_new_transactions<F: FnMut() -> bool>(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
mut should_continue: F,
) -> usize {
// Early out if nobody to send to.
@@ -159,7 +159,7 @@ impl SyncPropagator {
fn propagate_transactions_to_peers<F: FnMut() -> bool>(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peers: Vec<PeerId>,
transactions: Vec<&SignedTransaction>,
mut should_continue: F,
@@ -179,7 +179,7 @@ impl SyncPropagator {
// Clear old transactions from stats
sync.transactions_stats.retain(&all_transactions_hashes);
let send_packet = |io: &mut SyncIo, peer_id: PeerId, sent: usize, rlp: Bytes| {
let send_packet = |io: &mut dyn SyncIo, peer_id: PeerId, sent: usize, rlp: Bytes| {
let size = rlp.len();
SyncPropagator::send_packet(io, peer_id, TransactionsPacket, rlp);
trace!(target: "sync", "{:02} <- Transactions ({} entries; {} bytes)", peer_id, sent, size);
@@ -279,7 +279,7 @@ impl SyncPropagator {
sent_to_peers
}
pub fn propagate_latest_blocks(sync: &mut ChainSync, io: &mut SyncIo, sealed: &[H256]) {
pub fn propagate_latest_blocks(sync: &mut ChainSync, io: &mut dyn SyncIo, sealed: &[H256]) {
let chain_info = io.chain().chain_info();
if (((chain_info.best_block_number as i64) - (sync.last_sent_block_number as i64)).abs()
as BlockNumber)
@@ -304,7 +304,11 @@ impl SyncPropagator {
}
/// Distribute valid proposed blocks to subset of current peers.
pub fn propagate_proposed_blocks(sync: &mut ChainSync, io: &mut SyncIo, proposed: &[Bytes]) {
pub fn propagate_proposed_blocks(
sync: &mut ChainSync,
io: &mut dyn SyncIo,
proposed: &[Bytes],
) {
let peers = sync.get_consensus_peers();
trace!(target: "sync", "Sending proposed blocks to {:?}", peers);
for block in proposed {
@@ -316,7 +320,7 @@ impl SyncPropagator {
}
/// Broadcast consensus message to peers.
pub fn propagate_consensus_packet(sync: &mut ChainSync, io: &mut SyncIo, packet: Bytes) {
pub fn propagate_consensus_packet(sync: &mut ChainSync, io: &mut dyn SyncIo, packet: Bytes) {
let lucky_peers = ChainSync::select_random_peers(&sync.get_consensus_peers());
trace!(target: "sync", "Sending consensus packet to {:?}", lucky_peers);
for peer_id in lucky_peers {
@@ -327,7 +331,7 @@ impl SyncPropagator {
/// Broadcast private transaction message to peers.
pub fn propagate_private_transaction(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
transaction_hash: H256,
packet_id: SyncPacket,
packet: Bytes,
@@ -367,7 +371,12 @@ impl SyncPropagator {
}
/// Generic packet sender
pub fn send_packet(sync: &mut SyncIo, peer_id: PeerId, packet_id: SyncPacket, packet: Bytes) {
pub fn send_packet(
sync: &mut dyn SyncIo,
peer_id: PeerId,
packet_id: SyncPacket,
packet: Bytes,
) {
if let Err(e) = sync.send(peer_id, packet_id, packet) {
debug!(target:"sync", "Error sending packet: {:?}", e);
sync.disconnect_peer(peer_id);

View File

@@ -40,7 +40,7 @@ impl SyncRequester {
/// Perform block download request`
pub fn request_blocks(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
request: BlockRequest,
block_set: BlockSet,
@@ -63,7 +63,7 @@ impl SyncRequester {
/// Request block bodies from a peer
fn request_bodies(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
hashes: Vec<H256>,
set: BlockSet,
@@ -89,7 +89,7 @@ impl SyncRequester {
/// Request headers from a peer by block number
pub fn request_fork_header(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
n: BlockNumber,
) {
@@ -110,7 +110,7 @@ impl SyncRequester {
}
/// Find some headers or blocks to download for a peer.
pub fn request_snapshot_data(sync: &mut ChainSync, io: &mut SyncIo, peer_id: PeerId) {
pub fn request_snapshot_data(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId) {
// find chunk data to download
if let Some(hash) = sync.snapshot.needed_chunk() {
if let Some(ref mut peer) = sync.peers.get_mut(&peer_id) {
@@ -121,7 +121,7 @@ impl SyncRequester {
}
/// Request snapshot manifest from a peer.
pub fn request_snapshot_manifest(sync: &mut ChainSync, io: &mut SyncIo, peer_id: PeerId) {
pub fn request_snapshot_manifest(sync: &mut ChainSync, io: &mut dyn SyncIo, peer_id: PeerId) {
trace!(target: "sync", "{} <- GetSnapshotManifest", peer_id);
let rlp = RlpStream::new_list(0);
SyncRequester::send_request(
@@ -137,7 +137,7 @@ impl SyncRequester {
/// Request headers from a peer by block hash
fn request_headers_by_hash(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
h: &H256,
count: u64,
@@ -167,7 +167,7 @@ impl SyncRequester {
/// Request block receipts from a peer
fn request_receipts(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
hashes: Vec<H256>,
set: BlockSet,
@@ -193,7 +193,7 @@ impl SyncRequester {
/// Request snapshot chunk from a peer.
fn request_snapshot_chunk(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
chunk: &H256,
) {
@@ -213,7 +213,7 @@ impl SyncRequester {
/// Generic request sender
fn send_request(
sync: &mut ChainSync,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer_id: PeerId,
asking: PeerAsking,
packet_id: SyncPacket,

View File

@@ -49,7 +49,7 @@ impl SyncSupplier {
// to chain sync from the outside world.
pub fn dispatch_packet(
sync: &RwLock<ChainSync>,
io: &mut SyncIo,
io: &mut dyn SyncIo,
peer: PeerId,
packet_id: u8,
data: &[u8],
@@ -143,7 +143,7 @@ impl SyncSupplier {
}
/// Respond to GetBlockHeaders request
fn return_block_headers(io: &SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
fn return_block_headers(io: &dyn SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
let payload_soft_limit = io.payload_soft_limit();
// Packet layout:
// [ block: { P , B_32 }, maxHeaders: P, skip: P, reverse: P in { 0 , 1 } ]
@@ -226,7 +226,7 @@ impl SyncSupplier {
}
/// Respond to GetBlockBodies request
fn return_block_bodies(io: &SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
fn return_block_bodies(io: &dyn SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
let payload_soft_limit = io.payload_soft_limit();
let mut count = r.item_count().unwrap_or(0);
if count == 0 {
@@ -253,7 +253,7 @@ impl SyncSupplier {
}
/// Respond to GetNodeData request
fn return_node_data(io: &SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
fn return_node_data(io: &dyn SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
let payload_soft_limit = io.payload_soft_limit();
let mut count = r.item_count().unwrap_or(0);
trace!(target: "sync", "{} -> GetNodeData: {} entries", peer_id, count);
@@ -284,7 +284,7 @@ impl SyncSupplier {
Ok(Some((NodeDataPacket.id(), rlp)))
}
fn return_receipts(io: &SyncIo, rlp: &Rlp, peer_id: PeerId) -> RlpResponseResult {
fn return_receipts(io: &dyn SyncIo, rlp: &Rlp, peer_id: PeerId) -> RlpResponseResult {
let payload_soft_limit = io.payload_soft_limit();
let mut count = rlp.item_count().unwrap_or(0);
trace!(target: "sync", "{} -> GetReceipts: {} entries", peer_id, count);
@@ -313,7 +313,7 @@ impl SyncSupplier {
}
/// Respond to GetSnapshotManifest request
fn return_snapshot_manifest(io: &SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
fn return_snapshot_manifest(io: &dyn SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
let count = r.item_count().unwrap_or(0);
trace!(target: "warp", "{} -> GetSnapshotManifest", peer_id);
if count != 0 {
@@ -336,7 +336,7 @@ impl SyncSupplier {
}
/// Respond to GetSnapshotData request
fn return_snapshot_data(io: &SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
fn return_snapshot_data(io: &dyn SyncIo, r: &Rlp, peer_id: PeerId) -> RlpResponseResult {
let hash: H256 = r.val_at(0)?;
trace!(target: "warp", "{} -> GetSnapshotData {:?}", peer_id, hash);
let rlp = match io.snapshot_service().chunk(hash) {
@@ -355,14 +355,14 @@ impl SyncSupplier {
}
fn return_rlp<FRlp, FError>(
io: &mut SyncIo,
io: &mut dyn SyncIo,
rlp: &Rlp,
peer: PeerId,
rlp_func: FRlp,
error_func: FError,
) -> Result<(), PacketDecodeError>
where
FRlp: Fn(&SyncIo, &Rlp, PeerId) -> RlpResponseResult,
FRlp: Fn(&dyn SyncIo, &Rlp, PeerId) -> RlpResponseResult,
FError: FnOnce(network::Error) -> String,
{
let response = rlp_func(io, rlp, peer);
@@ -420,7 +420,7 @@ mod test {
client.add_blocks(100, EachBlockWith::Nothing);
let blocks: Vec<_> = (0..100)
.map(|i| {
(&client as &BlockChainClient)
(&client as &dyn BlockChainClient)
.block(BlockId::Number(i as BlockNumber))
.map(|b| b.into_inner())
.unwrap()

View File

@@ -118,7 +118,7 @@ impl AncestorSearch {
}
}
fn process_response<L>(self, ctx: &ResponseContext, client: &L) -> AncestorSearch
fn process_response<L>(self, ctx: &dyn ResponseContext, client: &L) -> AncestorSearch
where
L: AsLightClient,
{
@@ -261,7 +261,7 @@ impl Deref for SyncStateWrapper {
struct ResponseCtx<'a> {
peer: PeerId,
req_id: ReqId,
ctx: &'a BasicContext,
ctx: &'a dyn BasicContext,
data: &'a [encoded::Header],
}
@@ -302,7 +302,7 @@ struct PendingReq {
impl<L: AsLightClient + Send + Sync> Handler for LightSync<L> {
fn on_connect(
&self,
ctx: &EventContext,
ctx: &dyn EventContext,
status: &Status,
capabilities: &Capabilities,
) -> PeerStatus {
@@ -331,7 +331,7 @@ impl<L: AsLightClient + Send + Sync> Handler for LightSync<L> {
}
}
fn on_disconnect(&self, ctx: &EventContext, unfulfilled: &[ReqId]) {
fn on_disconnect(&self, ctx: &dyn EventContext, unfulfilled: &[ReqId]) {
let peer_id = ctx.peer();
let peer = match self.peers.write().remove(&peer_id).map(|p| p.into_inner()) {
@@ -389,7 +389,7 @@ impl<L: AsLightClient + Send + Sync> Handler for LightSync<L> {
self.maintain_sync(ctx.as_basic());
}
fn on_announcement(&self, ctx: &EventContext, announcement: &Announcement) {
fn on_announcement(&self, ctx: &dyn EventContext, announcement: &Announcement) {
let (last_td, chain_info) = {
let peers = self.peers.read();
match peers.get(&ctx.peer()) {
@@ -425,7 +425,7 @@ impl<L: AsLightClient + Send + Sync> Handler for LightSync<L> {
self.maintain_sync(ctx.as_basic());
}
fn on_responses(&self, ctx: &EventContext, req_id: ReqId, responses: &[request::Response]) {
fn on_responses(&self, ctx: &dyn EventContext, req_id: ReqId, responses: &[request::Response]) {
let peer = ctx.peer();
if !self.peers.read().contains_key(&peer) {
return;
@@ -469,7 +469,7 @@ impl<L: AsLightClient + Send + Sync> Handler for LightSync<L> {
self.maintain_sync(ctx.as_basic());
}
fn tick(&self, ctx: &BasicContext) {
fn tick(&self, ctx: &dyn BasicContext) {
self.maintain_sync(ctx);
}
}
@@ -502,7 +502,7 @@ impl<L: AsLightClient> LightSync<L> {
}
// handles request dispatch, block import, state machine transitions, and timeouts.
fn maintain_sync(&self, ctx: &BasicContext) {
fn maintain_sync(&self, ctx: &dyn BasicContext) {
use ethcore::error::{
Error as EthcoreError, ErrorKind as EthcoreErrorKind, ImportErrorKind,
};

View File

@@ -51,7 +51,7 @@ impl Snapshot {
}
/// Sync the Snapshot completed chunks with the Snapshot Service
pub fn initialize(&mut self, snapshot_service: &SnapshotService) {
pub fn initialize(&mut self, snapshot_service: &dyn SnapshotService) {
if self.initialized {
return;
}

View File

@@ -37,9 +37,9 @@ pub trait SyncIo {
/// Send a packet to a peer using specified protocol.
fn send(&mut self, peer_id: PeerId, packet_id: SyncPacket, data: Vec<u8>) -> Result<(), Error>;
/// Get the blockchain
fn chain(&self) -> &BlockChainClient;
fn chain(&self) -> &dyn BlockChainClient;
/// Get the snapshot service.
fn snapshot_service(&self) -> &SnapshotService;
fn snapshot_service(&self) -> &dyn SnapshotService;
/// Returns peer version identifier
fn peer_version(&self, peer_id: PeerId) -> ClientVersion {
ClientVersion::from(peer_id.to_string())
@@ -64,18 +64,18 @@ pub trait SyncIo {
/// Wraps `NetworkContext` and the blockchain client
pub struct NetSyncIo<'s> {
network: &'s NetworkContext,
chain: &'s BlockChainClient,
snapshot_service: &'s SnapshotService,
network: &'s dyn NetworkContext,
chain: &'s dyn BlockChainClient,
snapshot_service: &'s dyn SnapshotService,
chain_overlay: &'s RwLock<HashMap<BlockNumber, Bytes>>,
}
impl<'s> NetSyncIo<'s> {
/// Creates a new instance from the `NetworkContext` and the blockchain client reference.
pub fn new(
network: &'s NetworkContext,
chain: &'s BlockChainClient,
snapshot_service: &'s SnapshotService,
network: &'s dyn NetworkContext,
chain: &'s dyn BlockChainClient,
snapshot_service: &'s dyn SnapshotService,
chain_overlay: &'s RwLock<HashMap<BlockNumber, Bytes>>,
) -> NetSyncIo<'s> {
NetSyncIo {
@@ -105,7 +105,7 @@ impl<'s> SyncIo for NetSyncIo<'s> {
.send_protocol(packet_id.protocol(), peer_id, packet_id.id(), data)
}
fn chain(&self) -> &BlockChainClient {
fn chain(&self) -> &dyn BlockChainClient {
self.chain
}
@@ -113,7 +113,7 @@ impl<'s> SyncIo for NetSyncIo<'s> {
self.chain_overlay
}
fn snapshot_service(&self) -> &SnapshotService {
fn snapshot_service(&self) -> &dyn SnapshotService {
self.snapshot_service
}

View File

@@ -49,9 +49,9 @@ fn authority_round() {
let chain_id = Spec::new_test_round().chain_id();
let mut net = TestNet::with_spec(2, SyncConfig::default(), Spec::new_test_round);
let io_handler0: Arc<IoHandler<ClientIoMessage>> =
let io_handler0: Arc<dyn IoHandler<ClientIoMessage>> =
Arc::new(TestIoHandler::new(net.peer(0).chain.clone()));
let io_handler1: Arc<IoHandler<ClientIoMessage>> =
let io_handler1: Arc<dyn IoHandler<ClientIoMessage>> =
Arc::new(TestIoHandler::new(net.peer(1).chain.clone()));
// Push transaction to both clients. Only one of them gets lucky to produce a block.
net.peer(0)

View File

@@ -149,7 +149,7 @@ where
Ok(())
}
fn chain(&self) -> &BlockChainClient {
fn chain(&self) -> &dyn BlockChainClient {
&*self.chain
}
@@ -163,7 +163,7 @@ where
ClientVersion::from(client_id)
}
fn snapshot_service(&self) -> &SnapshotService {
fn snapshot_service(&self) -> &dyn SnapshotService {
self.snapshot_service
}

View File

@@ -58,9 +58,9 @@ fn send_private_transaction() {
let mut net = TestNet::with_spec(2, SyncConfig::default(), seal_spec);
let client0 = net.peer(0).chain.clone();
let client1 = net.peer(1).chain.clone();
let io_handler0: Arc<IoHandler<ClientIoMessage>> =
let io_handler0: Arc<dyn IoHandler<ClientIoMessage>> =
Arc::new(TestIoHandler::new(net.peer(0).chain.clone()));
let io_handler1: Arc<IoHandler<ClientIoMessage>> =
let io_handler1: Arc<dyn IoHandler<ClientIoMessage>> =
Arc::new(TestIoHandler::new(net.peer(1).chain.clone()));
net.peer(0)