Allow configuration of when to reseal blocks.
This commit is contained in:
@@ -133,6 +133,12 @@ Sealing/Mining Options:
|
||||
NOTE: MINING WILL NOT WORK WITHOUT THIS OPTION.
|
||||
--force-sealing Force the node to author new blocks as if it were
|
||||
always sealing/mining.
|
||||
--reseal-on-txs Specify which transactions should force the node
|
||||
to reseal a block. One of:
|
||||
none - never reseal on new transactions;
|
||||
own - reseal only on a new local transaction;
|
||||
ext - reseal only on a new external transaction;
|
||||
all - reseal on all new transactions [default: all].
|
||||
--usd-per-tx USD Amount of USD to be paid for a basic transaction
|
||||
[default: 0.005]. The minimum gas price is set
|
||||
accordingly.
|
||||
@@ -283,6 +289,7 @@ pub struct Args {
|
||||
pub flag_signer_path: String,
|
||||
pub flag_no_token: bool,
|
||||
pub flag_force_sealing: bool,
|
||||
pub flag_reseal_on_txs: String,
|
||||
pub flag_author: Option<String>,
|
||||
pub flag_usd_per_tx: String,
|
||||
pub flag_usd_per_eth: String,
|
||||
|
||||
@@ -27,6 +27,7 @@ use util::*;
|
||||
use ethcore::account_provider::AccountProvider;
|
||||
use util::network_settings::NetworkSettings;
|
||||
use ethcore::client::{append_path, get_db_path, ClientConfig, Switch, VMType};
|
||||
use ethcore::miner::MinerOptions;
|
||||
use ethcore::ethereum;
|
||||
use ethcore::spec::Spec;
|
||||
use ethsync::SyncConfig;
|
||||
@@ -67,6 +68,21 @@ impl Configuration {
|
||||
self.args.flag_maxpeers.unwrap_or(self.args.flag_peers) as u32
|
||||
}
|
||||
|
||||
pub fn miner_options(&self) -> MinerOptions {
|
||||
let (own, ext) = match self.args.flag_reseal_on_txs.as_str() {
|
||||
"none" => (false, false),
|
||||
"own" => (true, false),
|
||||
"ext" => (false, true),
|
||||
"all" => (true, true),
|
||||
x => die!("{}: Invalid value for --reseal option. Use --help for more information.", x)
|
||||
};
|
||||
MinerOptions {
|
||||
force_sealing: self.args.flag_force_sealing,
|
||||
reseal_on_external_tx: ext,
|
||||
reseal_on_own_tx: own,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn author(&self) -> Option<Address> {
|
||||
self.args.flag_etherbase.as_ref()
|
||||
.or(self.args.flag_author.as_ref())
|
||||
|
||||
@@ -208,7 +208,7 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
|
||||
let account_service = Arc::new(conf.account_service());
|
||||
|
||||
// Miner
|
||||
let miner = Miner::new(conf.args.flag_force_sealing, conf.spec(), Some(account_service.clone()));
|
||||
let miner = Miner::new(conf.miner_options(), conf.spec(), Some(account_service.clone()));
|
||||
miner.set_author(conf.author().unwrap_or_default());
|
||||
miner.set_gas_floor_target(conf.gas_floor_target());
|
||||
miner.set_gas_ceil_target(conf.gas_ceil_target());
|
||||
|
||||
Reference in New Issue
Block a user