mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Get rid of Peerset compatibility layer (#14337)
* Move bootnodes from individual `SetConfig`s to `PeersetConfig` * Move `SetId` & `SetConfig` from `peerset` to `protocol_controller` * Remove unused `DropReason` * Move `Message` & `IncomingIndex` from `peerset` to `protocol_controller` * Restore running fuzz test * Get rid of `Peerset` in `fuzz` test * Spawn runners instead of manual polling in `fuzz` test * Migrate `Protocol` from `Peerset` to `PeerStore` & `ProtocolController` * Migrate `NetworkService` from `Peerset` to `PeerStore` & `ProtocolController` * Migrate `Notifications` from `Peerset` to `ProtocolController`s * Migrate `Notifications` tests from `Peerset` to `ProtocolController` * Fix compilation of `NetworkService` & `Protocol` * Fix borrowing issues in `Notifications` * Migrate `RequestResponse`from `Peerset` to `PeerStore` * rustfmt * Migrate request-response tests from `Peerset` to `PeerStore` * Migrate `reconnect_after_disconnect` test to `PeerStore` & `ProtocolController` * Fix `Notifications` tests * Remove `Peerset` completely * Fix bug with counting sync peers in `Protocol` * Eliminate indirect calls to `PeerStore` via `Protocol` * Eliminate indirect calls to `ProtocolController` via `Protocol` * Handle `Err` outcome from `remove_peers_from_reserved_set` * Add note about disconnecting sync peers in `Protocol` * minor: remove unneeded `clone()` * minor: extra comma removed * minor: use `Stream` API of `from_protocol_controllers` channel * minor: remove TODO * minor: replace `.map().flatten()` with `.flat_map()` * minor: update `ProtocolController` docs * rustfmt * Apply suggestions from code review Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com> * Extract `MockPeerStore` to `mock.rs` * Move `PeerStore` initialization to `build_network` * minor: remove unused import * minor: clarify error message * Convert `syncs_header_only_forks` test into single-threaded --------- Co-authored-by: Aaro Altonen <48052676+altonen@users.noreply.github.com>
This commit is contained in:
@@ -238,10 +238,7 @@ impl<B: BlockT> Future for GossipEngine<B> {
|
||||
SyncEvent::PeerConnected(remote) =>
|
||||
this.network.add_set_reserved(remote, this.protocol.clone()),
|
||||
SyncEvent::PeerDisconnected(remote) =>
|
||||
this.network.remove_peers_from_reserved_set(
|
||||
this.protocol.clone(),
|
||||
vec![remote],
|
||||
),
|
||||
this.network.remove_set_reserved(remote, this.protocol.clone()),
|
||||
},
|
||||
// The sync event stream closed. Do the same for [`GossipValidator`].
|
||||
Poll::Ready(None) => {
|
||||
@@ -414,7 +411,13 @@ mod tests {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn remove_peers_from_reserved_set(&self, _protocol: ProtocolName, _peers: Vec<PeerId>) {}
|
||||
fn remove_peers_from_reserved_set(
|
||||
&self,
|
||||
_protocol: ProtocolName,
|
||||
_peers: Vec<PeerId>,
|
||||
) -> Result<(), String> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn sync_num_connected(&self) -> usize {
|
||||
unimplemented!();
|
||||
|
||||
@@ -89,6 +89,12 @@ pub trait Network<B: BlockT>: NetworkPeers + NetworkEventStream + NetworkNotific
|
||||
log::error!(target: "gossip", "add_set_reserved failed: {}", err);
|
||||
}
|
||||
}
|
||||
fn remove_set_reserved(&self, who: PeerId, protocol: ProtocolName) {
|
||||
let result = self.remove_peers_from_reserved_set(protocol, iter::once(who).collect());
|
||||
if let Err(err) = result {
|
||||
log::error!(target: "gossip", "remove_set_reserved failed: {}", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B: BlockT> Network<B> for T where T: NetworkPeers + NetworkEventStream + NetworkNotification {}
|
||||
|
||||
@@ -640,7 +640,13 @@ mod tests {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn remove_peers_from_reserved_set(&self, _protocol: ProtocolName, _peers: Vec<PeerId>) {}
|
||||
fn remove_peers_from_reserved_set(
|
||||
&self,
|
||||
_protocol: ProtocolName,
|
||||
_peers: Vec<PeerId>,
|
||||
) -> Result<(), String> {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
fn sync_num_connected(&self) -> usize {
|
||||
unimplemented!();
|
||||
|
||||
Reference in New Issue
Block a user