mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-30 02:37:27 +00:00
feat/ocw/bookkeeping (#5200)
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com> Co-Authored-By: Tomasz Drwięga <tomusdrw@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
f66168505b
commit
72ee7d5797
@@ -144,6 +144,12 @@ macro_rules! substrate_cli_subcommands {
|
||||
}
|
||||
}
|
||||
|
||||
fn offchain_worker_params(&self) -> Option<&$crate::OffchainWorkerParams> {
|
||||
match self {
|
||||
$($enum::$variant(cmd) => cmd.offchain_worker_params()),*
|
||||
}
|
||||
}
|
||||
|
||||
fn base_path(&self) -> $crate::Result<::std::option::Option<::std::path::PathBuf>> {
|
||||
match self {
|
||||
$($enum::$variant(cmd) => cmd.base_path()),*
|
||||
@@ -327,7 +333,7 @@ macro_rules! substrate_cli_subcommands {
|
||||
}
|
||||
}
|
||||
|
||||
fn offchain_worker(&self, role: &::sc_service::Role) -> $crate::Result<bool> {
|
||||
fn offchain_worker(&self, role: &::sc_service::Role) -> $crate::Result<::sc_service::config::OffchainWorkerConfig> {
|
||||
match self {
|
||||
$($enum::$variant(cmd) => cmd.offchain_worker(role)),*
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ use crate::params::KeystoreParams;
|
||||
use crate::params::NetworkParams;
|
||||
use crate::params::SharedParams;
|
||||
use crate::params::TransactionPoolParams;
|
||||
use crate::params::OffchainWorkerParams;
|
||||
use crate::CliConfiguration;
|
||||
use regex::Regex;
|
||||
use sc_service::{
|
||||
@@ -28,18 +29,7 @@ use sc_service::{
|
||||
};
|
||||
use sc_telemetry::TelemetryEndpoints;
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use structopt::{clap::arg_enum, StructOpt};
|
||||
|
||||
arg_enum! {
|
||||
/// Whether off-chain workers are enabled.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum OffchainWorkerEnabled {
|
||||
Always,
|
||||
Never,
|
||||
WhenValidating,
|
||||
}
|
||||
}
|
||||
use structopt::StructOpt;
|
||||
|
||||
/// The `run` command used to run a node.
|
||||
#[derive(Debug, StructOpt, Clone)]
|
||||
@@ -173,17 +163,9 @@ pub struct RunCmd {
|
||||
#[structopt(long = "telemetry-url", value_name = "URL VERBOSITY", parse(try_from_str = parse_telemetry_endpoints))]
|
||||
pub telemetry_endpoints: Vec<(String, u8)>,
|
||||
|
||||
/// Should execute offchain workers on every block.
|
||||
///
|
||||
/// By default it's only enabled for nodes that are authoring new blocks.
|
||||
#[structopt(
|
||||
long = "offchain-worker",
|
||||
value_name = "ENABLED",
|
||||
possible_values = &OffchainWorkerEnabled::variants(),
|
||||
case_insensitive = true,
|
||||
default_value = "WhenValidating"
|
||||
)]
|
||||
pub offchain_worker: OffchainWorkerEnabled,
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
pub offchain_worker_params: OffchainWorkerParams,
|
||||
|
||||
#[allow(missing_docs)]
|
||||
#[structopt(flatten)]
|
||||
@@ -300,6 +282,10 @@ impl CliConfiguration for RunCmd {
|
||||
Some(&self.keystore_params)
|
||||
}
|
||||
|
||||
fn offchain_worker_params(&self) -> Option<&OffchainWorkerParams> {
|
||||
Some(&self.offchain_worker_params)
|
||||
}
|
||||
|
||||
fn node_name(&self) -> Result<String> {
|
||||
let name: String = match (self.name.as_ref(), self.get_keyring()) {
|
||||
(Some(name), _) => name.to_string(),
|
||||
@@ -439,15 +425,6 @@ impl CliConfiguration for RunCmd {
|
||||
Ok(self.unsafe_rpc_expose)
|
||||
}
|
||||
|
||||
fn offchain_worker(&self, role: &Role) -> Result<bool> {
|
||||
Ok(match (&self.offchain_worker, role) {
|
||||
(OffchainWorkerEnabled::WhenValidating, Role::Authority { .. }) => true,
|
||||
(OffchainWorkerEnabled::Always, _) => true,
|
||||
(OffchainWorkerEnabled::Never, _) => false,
|
||||
(OffchainWorkerEnabled::WhenValidating, _) => false,
|
||||
})
|
||||
}
|
||||
|
||||
fn transaction_pool(&self) -> Result<TransactionPoolOptions> {
|
||||
Ok(self.pool_config.transaction_pool())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user