parent
5f103ee33d
commit
1f7fb1591d
@ -90,6 +90,8 @@ pub struct MinerOptions {
|
||||
pub reseal_on_own_tx: bool,
|
||||
/// Minimum period between transaction-inspired reseals.
|
||||
pub reseal_min_period: Duration,
|
||||
/// Maximum period between blocks (enables force sealing after that).
|
||||
pub reseal_max_period: Duration,
|
||||
/// Maximum amount of gas to bother considering for block insertion.
|
||||
pub tx_gas_limit: U256,
|
||||
/// Maximum size of the transaction queue.
|
||||
@ -123,6 +125,7 @@ impl Default for MinerOptions {
|
||||
tx_queue_strategy: PrioritizationStrategy::GasPriceOnly,
|
||||
pending_set: PendingSet::AlwaysQueue,
|
||||
reseal_min_period: Duration::from_secs(2),
|
||||
reseal_max_period: Duration::from_secs(120),
|
||||
work_queue_size: 20,
|
||||
enable_resubmission: true,
|
||||
tx_queue_banning: Banning::Disabled,
|
||||
@ -212,6 +215,7 @@ pub struct Miner {
|
||||
transaction_queue: Arc<Mutex<BanningTransactionQueue>>,
|
||||
sealing_work: Mutex<SealingWork>,
|
||||
next_allowed_reseal: Mutex<Instant>,
|
||||
next_mandatory_reseal: RwLock<Instant>,
|
||||
sealing_block_last_request: Mutex<u64>,
|
||||
// for sealing...
|
||||
options: MinerOptions,
|
||||
@ -268,6 +272,7 @@ impl Miner {
|
||||
Miner {
|
||||
transaction_queue: Arc::new(Mutex::new(txq)),
|
||||
next_allowed_reseal: Mutex::new(Instant::now()),
|
||||
next_mandatory_reseal: RwLock::new(Instant::now() + options.reseal_max_period),
|
||||
sealing_block_last_request: Mutex::new(0),
|
||||
sealing_work: Mutex::new(SealingWork{
|
||||
queue: UsingQueue::new(options.work_queue_size),
|
||||
@ -298,7 +303,9 @@ impl Miner {
|
||||
}
|
||||
|
||||
fn forced_sealing(&self) -> bool {
|
||||
self.options.force_sealing || !self.options.new_work_notify.is_empty()
|
||||
self.options.force_sealing
|
||||
|| !self.options.new_work_notify.is_empty()
|
||||
|| Instant::now() > *self.next_mandatory_reseal.read()
|
||||
}
|
||||
|
||||
/// Clear all pending block states
|
||||
@ -482,6 +489,7 @@ impl Miner {
|
||||
// Save proposal for later seal submission and broadcast it.
|
||||
Seal::Proposal(seal) => {
|
||||
trace!(target: "miner", "Received a Proposal seal.");
|
||||
*self.next_mandatory_reseal.write() = Instant::now() + self.options.reseal_max_period;
|
||||
{
|
||||
let mut sealing_work = self.sealing_work.lock();
|
||||
sealing_work.queue.push(block.clone());
|
||||
@ -497,7 +505,8 @@ impl Miner {
|
||||
})
|
||||
},
|
||||
// Directly import a regular sealed block.
|
||||
Seal::Regular(seal) =>
|
||||
Seal::Regular(seal) => {
|
||||
*self.next_mandatory_reseal.write() = Instant::now() + self.options.reseal_max_period;
|
||||
block
|
||||
.lock()
|
||||
.seal(&*self.engine, seal)
|
||||
@ -505,7 +514,8 @@ impl Miner {
|
||||
.unwrap_or_else(|e| {
|
||||
warn!("ERROR: seal failed when given internally generated seal: {}", e);
|
||||
false
|
||||
}),
|
||||
})
|
||||
},
|
||||
Seal::None => false,
|
||||
}
|
||||
} else {
|
||||
@ -1290,6 +1300,7 @@ mod tests {
|
||||
reseal_on_external_tx: false,
|
||||
reseal_on_own_tx: true,
|
||||
reseal_min_period: Duration::from_secs(5),
|
||||
reseal_max_period: Duration::from_secs(120),
|
||||
tx_gas_limit: !U256::zero(),
|
||||
tx_queue_size: 1024,
|
||||
tx_queue_gas_limit: GasLimit::None,
|
||||
|
@ -85,6 +85,7 @@ engine_signer = "0xdeadbeefcafe0000000000000000000000000001"
|
||||
force_sealing = true
|
||||
reseal_on_txs = "all"
|
||||
reseal_min_period = 4000
|
||||
reseal_max_period = 60000
|
||||
work_queue_size = 20
|
||||
relay_set = "cheap"
|
||||
usd_per_tx = "0.0025"
|
||||
|
@ -50,6 +50,7 @@ engine_signer = "0xdeadbeefcafe0000000000000000000000000001"
|
||||
force_sealing = true
|
||||
reseal_on_txs = "all"
|
||||
reseal_min_period = 4000
|
||||
reseal_max_period = 60000
|
||||
price_update_period = "hourly"
|
||||
tx_queue_size = 1024
|
||||
tx_queue_gas = "auto"
|
||||
|
@ -224,6 +224,8 @@ usage! {
|
||||
or |c: &Config| otry!(c.mining).reseal_on_txs.clone(),
|
||||
flag_reseal_min_period: u64 = 2000u64,
|
||||
or |c: &Config| otry!(c.mining).reseal_min_period.clone(),
|
||||
flag_reseal_max_period: u64 = 120000u64,
|
||||
or |c: &Config| otry!(c.mining).reseal_max_period.clone(),
|
||||
flag_work_queue_size: usize = 20usize,
|
||||
or |c: &Config| otry!(c.mining).work_queue_size.clone(),
|
||||
flag_tx_gas_limit: Option<String> = None,
|
||||
@ -460,6 +462,7 @@ struct Mining {
|
||||
force_sealing: Option<bool>,
|
||||
reseal_on_txs: Option<String>,
|
||||
reseal_min_period: Option<u64>,
|
||||
reseal_max_period: Option<u64>,
|
||||
work_queue_size: Option<usize>,
|
||||
tx_gas_limit: Option<String>,
|
||||
tx_time_limit: Option<u64>,
|
||||
@ -701,6 +704,7 @@ mod tests {
|
||||
flag_force_sealing: true,
|
||||
flag_reseal_on_txs: "all".into(),
|
||||
flag_reseal_min_period: 4000u64,
|
||||
flag_reseal_max_period: 60000u64,
|
||||
flag_work_queue_size: 20usize,
|
||||
flag_tx_gas_limit: Some("6283184".into()),
|
||||
flag_tx_time_limit: Some(100u64),
|
||||
@ -900,6 +904,7 @@ mod tests {
|
||||
force_sealing: Some(true),
|
||||
reseal_on_txs: Some("all".into()),
|
||||
reseal_min_period: Some(4000),
|
||||
reseal_max_period: Some(60000),
|
||||
work_queue_size: None,
|
||||
relay_set: None,
|
||||
usd_per_tx: None,
|
||||
|
@ -224,6 +224,9 @@ Sealing/Mining Options:
|
||||
--reseal-min-period MS Specify the minimum time between reseals from
|
||||
incoming transactions. MS is time measured in
|
||||
milliseconds (default: {flag_reseal_min_period}).
|
||||
--reseal-max-period MS Specify the maximum time since last block to enable
|
||||
force-sealing. MS is time measured in
|
||||
milliseconds (default: {flag_reseal_max_period}).
|
||||
--work-queue-size ITEMS Specify the number of historical work packages
|
||||
which are kept cached lest a solution is found for
|
||||
them later. High values take more memory but result
|
||||
|
@ -522,6 +522,7 @@ impl Configuration {
|
||||
tx_queue_strategy: to_queue_strategy(&self.args.flag_tx_queue_strategy)?,
|
||||
pending_set: to_pending_set(&self.args.flag_relay_set)?,
|
||||
reseal_min_period: Duration::from_millis(reseal_min_period),
|
||||
reseal_max_period: Duration::from_millis(self.args.flag_reseal_max_period),
|
||||
work_queue_size: self.args.flag_work_queue_size,
|
||||
enable_resubmission: !self.args.flag_remove_solved,
|
||||
tx_queue_banning: match self.args.flag_tx_time_limit {
|
||||
|
@ -64,6 +64,7 @@ fn miner_service(spec: &Spec, accounts: Arc<AccountProvider>) -> Arc<Miner> {
|
||||
tx_queue_banning: Banning::Disabled,
|
||||
pending_set: PendingSet::SealingOrElseQueue,
|
||||
reseal_min_period: Duration::from_secs(0),
|
||||
reseal_max_period: Duration::from_secs(120),
|
||||
work_queue_size: 50,
|
||||
enable_resubmission: true,
|
||||
refuse_service_transactions: false,
|
||||
|
Loading…
Reference in New Issue
Block a user