Skip to content

Commit

Permalink
AvN changes for additional configuration
Browse files Browse the repository at this point in the history
Adds additional configuration & parameters for a node
  • Loading branch information
thadouk committed Dec 8, 2020
1 parent 0db5c5b commit 060c420
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
16 changes: 16 additions & 0 deletions client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ pub struct RunCmd {
#[structopt(long)]
pub no_grandpa: bool,

/// AvN server port number
#[structopt(long = "avn-port", value_name = "AvN PORT")]
pub avn_port: Option<String>,

/// URL for connecting with an ethereum node
#[structopt(long = "ethereum-node-url", value_name = "ETH URL")]
pub eth_node_url: Option<String>,

/// Experimental: Run in light client mode.
#[structopt(long = "light", conflicts_with = "sentry")]
pub light: bool,
Expand Down Expand Up @@ -341,6 +349,14 @@ impl CliConfiguration for RunCmd {
}))
}

fn avn_port(&self) -> Result<Option<String>> {
Ok(self.avn_port.clone())
}

fn ethereum_node_url(&self) -> Result<Option<String>> {
Ok(self.eth_node_url.clone())
}

fn telemetry_endpoints(
&self,
chain_spec: &Box<dyn ChainSpec>,
Expand Down
16 changes: 16 additions & 0 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,20 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
Ok(Default::default())
}

/// Returns the avn port number as string
///
/// By default this is None.
fn avn_port(&self) -> Result<Option<String>> {
Ok(Default::default())
}

/// Returns the ethereum node URL as string
///
/// By default this is None.
fn ethereum_node_url(&self) -> Result<Option<String>> {
Ok(Default::default())
}

/// Get the development key seed from the current object
///
/// By default this is `None`.
Expand Down Expand Up @@ -506,6 +520,8 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
offchain_worker: self.offchain_worker(&role)?,
force_authoring: self.force_authoring()?,
disable_grandpa: self.disable_grandpa()?,
avn_port: self.avn_port()?,
ethereum_node_url: self.ethereum_node_url()?,
dev_key_seed: self.dev_key_seed(is_dev)?,
tracing_targets: self.tracing_targets()?,
tracing_receiver: self.tracing_receiver()?,
Expand Down
6 changes: 3 additions & 3 deletions client/keystore/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl std::error::Error for Error {
///
/// Every pair that is being generated by a `seed`, will be placed in memory.
pub struct Store {
path: Option<PathBuf>,
pub path: Option<PathBuf>,
/// Map over `(KeyTypeId, Raw public key)` -> `Key phrase/seed`
additional: HashMap<(KeyTypeId, Vec<u8>), String>,
password: Option<SecretString>,
Expand Down Expand Up @@ -210,7 +210,7 @@ impl Store {
}

/// Get the key phrase for a given public key and key type.
fn key_phrase_by_type(&self, public: &[u8], key_type: KeyTypeId) -> Result<String> {
pub fn key_phrase_by_type(&self, public: &[u8], key_type: KeyTypeId) -> Result<String> {
if let Some(phrase) = self.get_additional_pair(public, key_type) {
return Ok(phrase.clone())
}
Expand Down Expand Up @@ -269,7 +269,7 @@ impl Store {
}

/// Returns a list of raw public keys filtered by `KeyTypeId`
fn raw_public_keys(&self, id: KeyTypeId) -> Result<Vec<Vec<u8>>> {
pub fn raw_public_keys(&self, id: KeyTypeId) -> Result<Vec<Vec<u8>>> {
let mut public_keys: Vec<Vec<u8>> = self.additional.keys()
.into_iter()
.filter_map(|k| if k.0 == id { Some(k.1.clone()) } else { None })
Expand Down
4 changes: 4 additions & 0 deletions client/service/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ pub struct Configuration {
pub base_path: Option<BasePath>,
/// Configuration of the output format that the informant uses.
pub informant_output_format: sc_informant::OutputFormat,
/// AvN port number
pub avn_port: Option<String>,
/// Ethereum node Url
pub ethereum_node_url: Option<String>,
}

/// Type for tasks spawned by the executor.
Expand Down
2 changes: 2 additions & 0 deletions client/service/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ fn node_config<G: RuntimeGenesis + 'static, E: ChainSpecExtension + Clone + 'sta
announce_block: true,
base_path: Some(BasePath::new(root)),
informant_output_format: Default::default(),
avn_port: Default::default(),
ethereum_node_url: Default::default(),
}
}

Expand Down
2 changes: 2 additions & 0 deletions utils/browser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ where
enable_color: false,
prefix: String::new(),
},
avn_port: Default::default(),
ethereum_node_url: Default::default(),
};

Ok(config)
Expand Down

0 comments on commit 060c420

Please sign in to comment.