Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
[companion] Get rid of Peerset compatibility layer (#7355)
Browse files Browse the repository at this point in the history
* Update `NetworkPeers` trait interface

* update lockfile for {"substrate"}

---------

Co-authored-by: parity-processbot <>
  • Loading branch information
dmitry-markin authored and vstakhov committed Aug 3, 2023
1 parent 455d9ba commit fc0d952
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
14 changes: 11 additions & 3 deletions node/network/bridge/src/network.rs
Expand Up @@ -100,7 +100,11 @@ pub trait Network: Clone + Send + 'static {
) -> Result<(), String>;

/// Removes the peers for the protocol's peer set (both reserved and non-reserved).
async fn remove_from_peers_set(&mut self, protocol: ProtocolName, peers: Vec<PeerId>);
async fn remove_from_peers_set(
&mut self,
protocol: ProtocolName,
peers: Vec<PeerId>,
) -> Result<(), String>;

/// Send a request to a remote peer.
async fn start_request<AD: AuthorityDiscovery>(
Expand Down Expand Up @@ -135,8 +139,12 @@ impl Network for Arc<NetworkService<Block, Hash>> {
NetworkService::set_reserved_peers(&**self, protocol, multiaddresses)
}

async fn remove_from_peers_set(&mut self, protocol: ProtocolName, peers: Vec<PeerId>) {
NetworkService::remove_peers_from_reserved_set(&**self, protocol, peers);
async fn remove_from_peers_set(
&mut self,
protocol: ProtocolName,
peers: Vec<PeerId>,
) -> Result<(), String> {
NetworkService::remove_peers_from_reserved_set(&**self, protocol, peers)
}

fn report_peer(&self, who: PeerId, rep: ReputationChange) {
Expand Down
8 changes: 7 additions & 1 deletion node/network/bridge/src/rx/tests.rs
Expand Up @@ -118,7 +118,13 @@ impl Network for TestNetwork {
Ok(())
}

async fn remove_from_peers_set(&mut self, _protocol: ProtocolName, _: Vec<PeerId>) {}
async fn remove_from_peers_set(
&mut self,
_protocol: ProtocolName,
_: Vec<PeerId>,
) -> Result<(), String> {
Ok(())
}

async fn start_request<AD: AuthorityDiscovery>(
&self,
Expand Down
8 changes: 7 additions & 1 deletion node/network/bridge/src/tx/tests.rs
Expand Up @@ -105,7 +105,13 @@ impl Network for TestNetwork {
Ok(())
}

async fn remove_from_peers_set(&mut self, _protocol: ProtocolName, _: Vec<PeerId>) {}
async fn remove_from_peers_set(
&mut self,
_protocol: ProtocolName,
_: Vec<PeerId>,
) -> Result<(), String> {
Ok(())
}

async fn start_request<AD: AuthorityDiscovery>(
&self,
Expand Down
7 changes: 6 additions & 1 deletion node/network/bridge/src/validator_discovery.rs
Expand Up @@ -236,8 +236,13 @@ mod tests {
Ok(())
}

async fn remove_from_peers_set(&mut self, _protocol: ProtocolName, peers: Vec<PeerId>) {
async fn remove_from_peers_set(
&mut self,
_protocol: ProtocolName,
peers: Vec<PeerId>,
) -> Result<(), String> {
self.peers_set.retain(|elem| !peers.contains(elem));
Ok(())
}

async fn start_request<AD: AuthorityDiscovery>(
Expand Down

0 comments on commit fc0d952

Please sign in to comment.