mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 17:01:09 +00:00
Infrastructure improvements (#2897)
* Factor out runtime module into utils. * Add maybe_authority information to `PeerConnected` event. We already gather this information in authority discovery, so we might as well share it with others. This opens up an easy path to trigger validators differently from normal nodes, e.g. for prioritization. This change has become more important now, that we just connect to all validators and therefore just have a long peer list without any information about those nodes. * Test fix.
This commit is contained in:
@@ -17,13 +17,15 @@
|
||||
use std::convert::TryFrom;
|
||||
|
||||
pub use sc_network::{ReputationChange, PeerId};
|
||||
|
||||
use polkadot_node_network_protocol::{WrongVariant, ObservedRole, OurView, View};
|
||||
use polkadot_primitives::v1::AuthorityDiscoveryId;
|
||||
|
||||
/// Events from network.
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum NetworkBridgeEvent<M> {
|
||||
/// A peer has connected.
|
||||
PeerConnected(PeerId, ObservedRole),
|
||||
PeerConnected(PeerId, ObservedRole, Option<AuthorityDiscoveryId>),
|
||||
|
||||
/// A peer has disconnected.
|
||||
PeerDisconnected(PeerId),
|
||||
@@ -58,8 +60,8 @@ impl<M> NetworkBridgeEvent<M> {
|
||||
where T: 'a + Clone, &'a T: TryFrom<&'a M, Error = WrongVariant>
|
||||
{
|
||||
Ok(match *self {
|
||||
NetworkBridgeEvent::PeerConnected(ref peer, ref role)
|
||||
=> NetworkBridgeEvent::PeerConnected(peer.clone(), role.clone()),
|
||||
NetworkBridgeEvent::PeerConnected(ref peer, ref role, ref authority_id)
|
||||
=> NetworkBridgeEvent::PeerConnected(peer.clone(), role.clone(), authority_id.clone()),
|
||||
NetworkBridgeEvent::PeerDisconnected(ref peer)
|
||||
=> NetworkBridgeEvent::PeerDisconnected(peer.clone()),
|
||||
NetworkBridgeEvent::PeerMessage(ref peer, ref msg)
|
||||
|
||||
Reference in New Issue
Block a user