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
@@ -27,7 +27,7 @@ use sp_runtime::BuildStorage;
use serde_json as json;
use crate::RuntimeGenesis;
use crate::extension::GetExtension;
use sc_network::Multiaddr;
use sc_network::config::MultiaddrWithPeerId;
use sc_telemetry::TelemetryEndpoints;
enum GenesisSource<G> {
@@ -137,7 +137,7 @@ enum Genesis<G> {
struct ClientSpec<E> {
name: String,
id: String,
boot_nodes: Vec<String>,
boot_nodes: Vec<MultiaddrWithPeerId>,
telemetry_endpoints: Option<TelemetryEndpoints>,
protocol_id: Option<String>,
properties: Option<Properties>,
@@ -174,7 +174,7 @@ impl<G, E: Clone> Clone for ChainSpec<G, E> {
impl<G, E> ChainSpec<G, E> {
/// A list of bootnode addresses.
pub fn boot_nodes(&self) -> &[String] {
pub fn boot_nodes(&self) -> &[MultiaddrWithPeerId] {
&self.client_spec.boot_nodes
}
@@ -206,8 +206,8 @@ impl<G, E> ChainSpec<G, E> {
}
/// Add a bootnode to the list.
pub fn add_boot_node(&mut self, addr: Multiaddr) {
self.client_spec.boot_nodes.push(addr.to_string())
pub fn add_boot_node(&mut self, addr: MultiaddrWithPeerId) {
self.client_spec.boot_nodes.push(addr)
}
/// Returns a reference to defined chain spec extensions.
@@ -220,7 +220,7 @@ impl<G, E> ChainSpec<G, E> {
name: &str,
id: &str,
constructor: F,
boot_nodes: Vec<String>,
boot_nodes: Vec<MultiaddrWithPeerId>,
telemetry_endpoints: Option<TelemetryEndpoints>,
protocol_id: Option<&str>,
properties: Option<Properties>,
@@ -320,7 +320,7 @@ where
G: RuntimeGenesis,
E: GetExtension + serde::Serialize + Clone + Send,
{
fn boot_nodes(&self) -> &[String] {
fn boot_nodes(&self) -> &[MultiaddrWithPeerId] {
ChainSpec::boot_nodes(self)
}
@@ -344,7 +344,7 @@ where
ChainSpec::properties(self)
}
fn add_boot_node(&mut self, addr: Multiaddr) {
fn add_boot_node(&mut self, addr: MultiaddrWithPeerId) {
ChainSpec::add_boot_node(self, addr)
}
+3 -3
View File
@@ -117,7 +117,7 @@ pub use sc_chain_spec_derive::{ChainSpecExtension, ChainSpecGroup};
use serde::{Serialize, de::DeserializeOwned};
use sp_runtime::BuildStorage;
use sc_network::Multiaddr;
use sc_network::config::MultiaddrWithPeerId;
use sc_telemetry::TelemetryEndpoints;
/// A set of traits for the runtime genesis config.
@@ -131,7 +131,7 @@ pub trait ChainSpec: BuildStorage + Send {
/// Spec id.
fn id(&self) -> &str;
/// A list of bootnode addresses.
fn boot_nodes(&self) -> &[String];
fn boot_nodes(&self) -> &[MultiaddrWithPeerId];
/// Telemetry endpoints (if any)
fn telemetry_endpoints(&self) -> &Option<TelemetryEndpoints>;
/// Network protocol id.
@@ -143,7 +143,7 @@ pub trait ChainSpec: BuildStorage + Send {
/// Returns a reference to defined chain spec extensions.
fn extensions(&self) -> &dyn GetExtension;
/// Add a bootnode to the list.
fn add_boot_node(&mut self, addr: Multiaddr);
fn add_boot_node(&mut self, addr: MultiaddrWithPeerId);
/// Return spec as JSON.
fn as_json(&self, raw: bool) -> Result<String, String>;
/// Return StorageBuilder for this spec.