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:
Pierre Krieger
2020-04-03 19:08:14 +02:00
committed by GitHub
parent 9dbcb11f66
commit 8c03a4fcef
44 changed files with 591 additions and 432 deletions
+9 -12
View File
@@ -58,7 +58,7 @@ pub use self::builder::{
ServiceBuilder, ServiceBuilderCommand, TFullClient, TLightClient, TFullBackend, TLightBackend,
TFullCallExecutor, TLightCallExecutor,
};
pub use config::{Configuration, Roles, PruningMode, DatabaseConfig};
pub use config::{Configuration, Role, PruningMode, DatabaseConfig};
pub use sc_chain_spec::{
ChainSpec, GenericChainSpec, Properties, RuntimeGenesis, Extension as ChainSpecExtension
};
@@ -322,7 +322,7 @@ fn build_network_future<
C: sc_client::BlockchainEvents<B>,
H: sc_network::ExHashT
> (
roles: Roles,
role: Role,
mut network: sc_network::NetworkWorker<B, H>,
client: Arc<C>,
status_sinks: Arc<Mutex<status_sinks::StatusSinks<(NetworkStatus<B>, NetworkState)>>>,
@@ -399,17 +399,14 @@ fn build_network_future<
sc_rpc::system::Request::NodeRoles(sender) => {
use sc_rpc::system::NodeRole;
let node_roles = (0 .. 8)
.filter(|&bit_number| (roles.bits() >> bit_number) & 1 == 1)
.map(|bit_number| match Roles::from_bits(1 << bit_number) {
Some(Roles::AUTHORITY) => NodeRole::Authority,
Some(Roles::LIGHT) => NodeRole::LightClient,
Some(Roles::FULL) => NodeRole::Full,
_ => NodeRole::UnknownRole(bit_number),
})
.collect();
let node_role = match role {
Role::Authority { .. } => NodeRole::Authority,
Role::Light => NodeRole::LightClient,
Role::Full => NodeRole::Full,
Role::Sentry { .. } => NodeRole::Sentry,
};
let _ = sender.send(node_roles);
let _ = sender.send(vec![node_role]);
}
};
}