mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 08:41:07 +00:00
improved gossip topology (#3270)
* gossip-support: gossip topology * some fixes * handle view update for newly added gossip peers * fix neighbors calculation * fix test * resolve TODOs * typo * guide updates * spaces in the guide * sneaky spaces * hash randomness * address some review nits * use unbounded in bridge for subsystem msg
This commit is contained in:
@@ -35,7 +35,7 @@ use polkadot_node_network_protocol::{
|
||||
request_response::{OutgoingRequest, Requests, Recipient},
|
||||
PeerId, UnifiedReputationChange as Rep,
|
||||
};
|
||||
use polkadot_primitives::v1::{Block, Hash};
|
||||
use polkadot_primitives::v1::{AuthorityDiscoveryId, Block, Hash};
|
||||
use polkadot_subsystem::{SubsystemError, SubsystemResult};
|
||||
|
||||
use crate::validator_discovery::AuthorityDiscovery;
|
||||
@@ -303,3 +303,17 @@ impl Network for Arc<NetworkService<Block, Hash>> {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// We assume one peer_id per authority_id.
|
||||
pub async fn get_peer_id_by_authority_id<AD: AuthorityDiscovery>(
|
||||
authority_discovery: &mut AD,
|
||||
authority: AuthorityDiscoveryId,
|
||||
) -> Option<PeerId> {
|
||||
// Note: `get_addresses_by_authority_id` searched in a cache, and it thus expected
|
||||
// to be very quick.
|
||||
authority_discovery
|
||||
.get_addresses_by_authority_id(authority).await
|
||||
.into_iter()
|
||||
.flat_map(|list| list.into_iter())
|
||||
.find_map(|addr| parse_addr(addr).ok().map(|(p, _)| p))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user