mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Use grid topology for bitfileds distribution messages (#5389)
* Move NewGossipTopology -> SessionGridTopology outside as this implementation is shared * Add method to return peers difference between topologies * Implement basic grid topology usage for the bitfield distribution * Fix tests * Oops, fix tests * Add some tests for random routing * Add a unit test for topology distribution * Store the current and the previous topology to match sessions boundaries * Update tests * Update node/network/bitfield-distribution/src/lib.rs Co-authored-by: Andronik <write@reusable.software> * Update node/network/protocol/src/grid_topology.rs Co-authored-by: Andronik <write@reusable.software> * Update node/network/bitfield-distribution/src/lib.rs Co-authored-by: Andronik <write@reusable.software> * Add some debug * Fix tests as HashSet order is undefined Co-authored-by: Andronik <write@reusable.software>
This commit is contained in:
@@ -21,7 +21,9 @@ use std::{
|
||||
|
||||
pub use sc_network::{PeerId, ReputationChange};
|
||||
|
||||
use polkadot_node_network_protocol::{ObservedRole, OurView, ProtocolVersion, View, WrongVariant};
|
||||
use polkadot_node_network_protocol::{
|
||||
grid_topology::SessionGridTopology, ObservedRole, OurView, ProtocolVersion, View, WrongVariant,
|
||||
};
|
||||
use polkadot_primitives::v2::{AuthorityDiscoveryId, SessionIndex, ValidatorIndex};
|
||||
|
||||
/// Information about a peer in the gossip topology for a session.
|
||||
@@ -119,3 +121,19 @@ impl<M> NetworkBridgeEvent<M> {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl From<NewGossipTopology> for SessionGridTopology {
|
||||
fn from(topology: NewGossipTopology) -> Self {
|
||||
let peers_x =
|
||||
topology.our_neighbors_x.values().flat_map(|p| &p.peer_ids).cloned().collect();
|
||||
let peers_y =
|
||||
topology.our_neighbors_y.values().flat_map(|p| &p.peer_ids).cloned().collect();
|
||||
|
||||
let validator_indices_x =
|
||||
topology.our_neighbors_x.values().map(|p| p.validator_index.clone()).collect();
|
||||
let validator_indices_y =
|
||||
topology.our_neighbors_y.values().map(|p| p.validator_index.clone()).collect();
|
||||
|
||||
SessionGridTopology { peers_x, peers_y, validator_indices_x, validator_indices_y }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user