polkadot_node_network_protocol/
authority_discovery.rs1use std::{collections::HashSet, fmt::Debug};
20
21use async_trait::async_trait;
22
23use sc_authority_discovery::Service as AuthorityDiscoveryService;
24
25use polkadot_primitives::AuthorityDiscoveryId;
26use sc_network::Multiaddr;
27use sc_network_types::PeerId;
28
29#[async_trait]
33pub trait AuthorityDiscovery: Send + Debug + 'static {
34 async fn get_addresses_by_authority_id(
36 &mut self,
37 authority: AuthorityDiscoveryId,
38 ) -> Option<HashSet<Multiaddr>>;
39 async fn get_authority_ids_by_peer_id(
41 &mut self,
42 peer_id: PeerId,
43 ) -> Option<HashSet<AuthorityDiscoveryId>>;
44}
45
46#[async_trait]
47impl AuthorityDiscovery for AuthorityDiscoveryService {
48 async fn get_addresses_by_authority_id(
49 &mut self,
50 authority: AuthorityDiscoveryId,
51 ) -> Option<HashSet<Multiaddr>> {
52 AuthorityDiscoveryService::get_addresses_by_authority_id(self, authority).await
53 }
54
55 async fn get_authority_ids_by_peer_id(
56 &mut self,
57 peer_id: PeerId,
58 ) -> Option<HashSet<AuthorityDiscoveryId>> {
59 AuthorityDiscoveryService::get_authority_ids_by_peer_id(self, peer_id).await
60 }
61}