From 5f03528db207c55199a3532d419538d34730366b Mon Sep 17 00:00:00 2001 From: Aaro Altonen Date: Sun, 20 Nov 2022 12:40:59 +0200 Subject: [PATCH] Companion for paritytech/substrate#12739 --- .../relay-chain-minimal-node/src/network.rs | 100 ++++-------------- 1 file changed, 18 insertions(+), 82 deletions(-) diff --git a/client/relay-chain-minimal-node/src/network.rs b/client/relay-chain-minimal-node/src/network.rs index bd4b0889a89..a85fb8d7377 100644 --- a/client/relay-chain-minimal-node/src/network.rs +++ b/client/relay-chain-minimal-node/src/network.rs @@ -27,7 +27,10 @@ use sc_network_common::{ }, protocol::role::Roles, service::NetworkSyncForkRequest, - sync::{message::BlockAnnouncesHandshake, Metrics, SyncStatus}, + sync::{ + message::{BlockAnnouncesHandshake, BlockRequest}, + Metrics, SyncStatus, + }, }; use sc_network_light::light_client_requests; use sc_network_sync::{block_request_handler, state_request_handler}; @@ -94,11 +97,12 @@ pub(crate) fn build_collator_network( metrics_registry: config.prometheus_config.as_ref().map(|config| config.registry.clone()), block_announce_config, chain_sync_service: Box::new(DummyChainSyncService::(Default::default())), - block_request_protocol_config, - state_request_protocol_config, - warp_sync_protocol_config: None, - light_client_request_protocol_config, - request_response_protocol_configs: Vec::new(), + request_response_protocol_configs: [ + block_request_protocol_config, + state_request_protocol_config, + light_client_request_protocol_config, + ] + .to_vec(), }; let network_worker = sc_network::NetworkWorker::new(network_params)?; @@ -248,30 +252,6 @@ impl sc_network_common::sync::ChainSync for DummyChainSync { ) { } - fn justification_requests( - &mut self, - ) -> Box)> + '_> - { - Box::new(std::iter::empty()) - } - - fn block_requests( - &mut self, - ) -> Box)> + '_> - { - Box::new(std::iter::empty()) - } - - fn state_request(&mut self) -> Option<(PeerId, sc_network_common::sync::OpaqueStateRequest)> { - None - } - - fn warp_sync_request( - &mut self, - ) -> Option<(PeerId, sc_network_common::sync::warp::WarpProofRequest)> { - None - } - fn on_block_data( &mut self, _who: &PeerId, @@ -281,22 +261,6 @@ impl sc_network_common::sync::ChainSync for DummyChainSync { unimplemented!("Not supported on the RPC collator") } - fn on_state_data( - &mut self, - _who: &PeerId, - _response: sc_network_common::sync::OpaqueStateResponse, - ) -> Result, sc_network_common::sync::BadPeer> { - unimplemented!("Not supported on the RPC collator") - } - - fn on_warp_sync_data( - &mut self, - _who: &PeerId, - _response: sc_network_common::sync::warp::EncodedProof, - ) -> Result<(), sc_network_common::sync::BadPeer> { - unimplemented!("Not supported on the RPC collator") - } - fn on_block_justification( &mut self, _who: PeerId, @@ -380,27 +344,6 @@ impl sc_network_common::sync::ChainSync for DummyChainSync { } } - fn create_opaque_block_request( - &self, - _request: &sc_network_common::sync::message::BlockRequest, - ) -> sc_network_common::sync::OpaqueBlockRequest { - unimplemented!("Not supported on the RPC collator") - } - - fn encode_block_request( - &self, - _request: &sc_network_common::sync::OpaqueBlockRequest, - ) -> Result, String> { - unimplemented!("Not supported on the RPC collator") - } - - fn decode_block_response( - &self, - _response: &[u8], - ) -> Result { - unimplemented!("Not supported on the RPC collator") - } - fn block_response_into_blocks( &self, _request: &sc_network_common::sync::message::BlockRequest, @@ -409,26 +352,19 @@ impl sc_network_common::sync::ChainSync for DummyChainSync { unimplemented!("Not supported on the RPC collator") } - fn encode_state_request( - &self, - _request: &sc_network_common::sync::OpaqueStateRequest, - ) -> Result, String> { - unimplemented!("Not supported on the RPC collator") + fn poll( + &mut self, + _cx: &mut std::task::Context, + ) -> std::task::Poll> { + std::task::Poll::Pending } - fn decode_state_response( - &self, - _response: &[u8], - ) -> Result { + fn send_block_request(&mut self, _who: PeerId, _request: BlockRequest) { unimplemented!("Not supported on the RPC collator") } - fn poll( - &mut self, - _cx: &mut std::task::Context, - ) -> std::task::Poll::Header>> - { - std::task::Poll::Pending + fn num_active_peers(&self) -> usize { + 0 } }