mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 01:07:57 +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:
@@ -82,7 +82,7 @@ impl ImportParams {
|
||||
pub fn update_config(
|
||||
&self,
|
||||
mut config: &mut Configuration,
|
||||
role: sc_service::Roles,
|
||||
role: &sc_service::Role,
|
||||
is_dev: bool,
|
||||
) -> error::Result<()> {
|
||||
use sc_client_api::execution_extensions::ExecutionStrategies;
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::iter;
|
||||
use std::net::Ipv4Addr;
|
||||
use structopt::StructOpt;
|
||||
use sc_network::{
|
||||
config::{NonReservedPeerMode, TransportConfig}, multiaddr::Protocol,
|
||||
config::{MultiaddrWithPeerId, NonReservedPeerMode, TransportConfig}, multiaddr::Protocol, Multiaddr,
|
||||
};
|
||||
use sc_service::Configuration;
|
||||
|
||||
@@ -30,12 +30,12 @@ use crate::params::node_key_params::NodeKeyParams;
|
||||
#[derive(Debug, StructOpt, Clone)]
|
||||
pub struct NetworkConfigurationParams {
|
||||
/// Specify a list of bootnodes.
|
||||
#[structopt(long = "bootnodes", value_name = "URL")]
|
||||
pub bootnodes: Vec<String>,
|
||||
#[structopt(long = "bootnodes", value_name = "ADDR")]
|
||||
pub bootnodes: Vec<MultiaddrWithPeerId>,
|
||||
|
||||
/// Specify a list of reserved node addresses.
|
||||
#[structopt(long = "reserved-nodes", value_name = "URL")]
|
||||
pub reserved_nodes: Vec<String>,
|
||||
#[structopt(long = "reserved-nodes", value_name = "ADDR")]
|
||||
pub reserved_nodes: Vec<MultiaddrWithPeerId>,
|
||||
|
||||
/// Whether to only allow connections to/from reserved nodes.
|
||||
///
|
||||
@@ -47,14 +47,14 @@ pub struct NetworkConfigurationParams {
|
||||
/// Specify a list of sentry node public addresses.
|
||||
#[structopt(
|
||||
long = "sentry-nodes",
|
||||
value_name = "URL",
|
||||
value_name = "ADDR",
|
||||
conflicts_with_all = &[ "sentry" ]
|
||||
)]
|
||||
pub sentry_nodes: Vec<String>,
|
||||
pub sentry_nodes: Vec<MultiaddrWithPeerId>,
|
||||
|
||||
/// Listen on this multiaddress.
|
||||
#[structopt(long = "listen-addr", value_name = "LISTEN_ADDR")]
|
||||
pub listen_addr: Vec<String>,
|
||||
pub listen_addr: Vec<Multiaddr>,
|
||||
|
||||
/// Specify p2p protocol TCP port.
|
||||
///
|
||||
@@ -117,13 +117,7 @@ impl NetworkConfigurationParams {
|
||||
config.network.non_reserved_mode = NonReservedPeerMode::Deny;
|
||||
}
|
||||
|
||||
config.network.sentry_nodes.extend(self.sentry_nodes.clone());
|
||||
|
||||
for addr in self.listen_addr.iter() {
|
||||
let addr = addr.parse().ok().ok_or(error::Error::InvalidListenMultiaddress)?;
|
||||
config.network.listen_addresses.push(addr);
|
||||
}
|
||||
|
||||
config.network.listen_addresses.extend(self.listen_addr.iter().cloned());
|
||||
if config.network.listen_addresses.is_empty() {
|
||||
let port = match self.port {
|
||||
Some(port) => port,
|
||||
|
||||
@@ -36,7 +36,7 @@ impl PruningParams {
|
||||
pub fn update_config(
|
||||
&self,
|
||||
mut config: &mut Configuration,
|
||||
role: sc_service::Roles,
|
||||
role: &sc_service::Role,
|
||||
unsafe_pruning: bool,
|
||||
) -> error::Result<()> {
|
||||
// by default we disable pruning if the node is an authority (i.e.
|
||||
@@ -45,10 +45,10 @@ impl PruningParams {
|
||||
// unless `unsafe_pruning` is set.
|
||||
config.pruning = match &self.pruning {
|
||||
Some(ref s) if s == "archive" => PruningMode::ArchiveAll,
|
||||
None if role == sc_service::Roles::AUTHORITY => PruningMode::ArchiveAll,
|
||||
None if role.is_network_authority() => PruningMode::ArchiveAll,
|
||||
None => PruningMode::default(),
|
||||
Some(s) => {
|
||||
if role == sc_service::Roles::AUTHORITY && !unsafe_pruning {
|
||||
if role.is_network_authority() && !unsafe_pruning {
|
||||
return Err(error::Error::Input(
|
||||
"Validators should run with state pruning disabled (i.e. archive). \
|
||||
You can ignore this check with `--unsafe-pruning`.".to_string()
|
||||
|
||||
Reference in New Issue
Block a user