mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-08 12:27:22 +00:00
Move block/state/warpc sync requests/responses to ChainSync (#12739)
* Move block/state/warpc sync requests/responses to `ChainSync` * Apply suggestions from code review Co-authored-by: Bastian Köcher <git@kchr.de> * Apply review suggestions * cargo-fmt + doc fix * Fix tests Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
@@ -16,13 +16,16 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
use sc_network_common::service::{NetworkPeers, NetworkSyncForkRequest};
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
|
||||
pub use libp2p::{identity::error::SigningError, kad::record::Key as KademliaKey};
|
||||
use futures::channel::oneshot;
|
||||
use libp2p::{Multiaddr, PeerId};
|
||||
use sc_network_common::{config::MultiaddrWithPeerId, protocol::ProtocolName};
|
||||
use sc_network_common::{
|
||||
config::MultiaddrWithPeerId,
|
||||
protocol::ProtocolName,
|
||||
request_responses::{IfDisconnected, RequestFailure},
|
||||
service::{NetworkPeers, NetworkRequest, NetworkSyncForkRequest},
|
||||
};
|
||||
use sc_peerset::ReputationChange;
|
||||
use sp_runtime::traits::{Block as BlockT, NumberFor};
|
||||
use std::collections::HashSet;
|
||||
|
||||
mockall::mock! {
|
||||
@@ -72,4 +75,23 @@ mockall::mock! {
|
||||
fn remove_from_peers_set(&self, protocol: ProtocolName, peers: Vec<PeerId>);
|
||||
fn sync_num_connected(&self) -> usize;
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl NetworkRequest for Network {
|
||||
async fn request(
|
||||
&self,
|
||||
target: PeerId,
|
||||
protocol: ProtocolName,
|
||||
request: Vec<u8>,
|
||||
connect: IfDisconnected,
|
||||
) -> Result<Vec<u8>, RequestFailure>;
|
||||
fn start_request(
|
||||
&self,
|
||||
target: PeerId,
|
||||
protocol: ProtocolName,
|
||||
request: Vec<u8>,
|
||||
tx: oneshot::Sender<Result<Vec<u8>, RequestFailure>>,
|
||||
connect: IfDisconnected,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user