mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-28 15:37:27 +00:00
Split the Roles in three types (#5520)
* Split the Roles bitfield in three * Forgot to include some changes * Fix cli test * More test fixes * Oh God, merging master broke other tests * Didn't run the doctests * Address review * I'm trying to fix the build blindly because it's taking a good hour to compile on my machine * Address some review * Also update the peerset's API to make sense * Fix peerset tests * Fix browser node * client: distinguish between local and network authority Co-authored-by: André Silva <andre.beat@gmail.com>
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
//! Network event types. These are are not the part of the protocol, but rather
|
||||
//! events that happen on the network like DHT get/put results received.
|
||||
|
||||
use crate::config::Roles;
|
||||
use bytes::Bytes;
|
||||
use libp2p::core::PeerId;
|
||||
use libp2p::kad::record::Key;
|
||||
@@ -55,8 +54,8 @@ pub enum Event {
|
||||
remote: PeerId,
|
||||
/// The concerned protocol. Each protocol uses a different substream.
|
||||
engine_id: ConsensusEngineId,
|
||||
/// Roles that the remote .
|
||||
roles: Roles,
|
||||
/// Role of the remote.
|
||||
role: ObservedRole,
|
||||
},
|
||||
|
||||
/// Closed a substream with the given node. Always matches a corresponding previous
|
||||
@@ -76,3 +75,26 @@ pub enum Event {
|
||||
messages: Vec<(ConsensusEngineId, Bytes)>,
|
||||
},
|
||||
}
|
||||
|
||||
/// Role that the peer sent to us during the handshake, with the addition of what our local node
|
||||
/// knows about that peer.
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum ObservedRole {
|
||||
/// Full node.
|
||||
Full,
|
||||
/// Light node.
|
||||
Light,
|
||||
/// When we are a validator node, this is a sentry that protects us.
|
||||
OurSentry,
|
||||
/// When we are a sentry node, this is the authority we are protecting.
|
||||
OurGuardedAuthority,
|
||||
/// Third-party authority.
|
||||
Authority,
|
||||
}
|
||||
|
||||
impl ObservedRole {
|
||||
/// Returns `true` for `ObservedRole::Light`.
|
||||
pub fn is_light(&self) -> bool {
|
||||
matches!(self, ObservedRole::Light)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user