method to check if default address is_sealer
This commit is contained in:
parent
2bd82269e8
commit
0880d4ad8f
@ -72,8 +72,10 @@ pub trait Engine : Sync + Send {
|
|||||||
fn on_close_block(&self, _block: &mut ExecutedBlock) {}
|
fn on_close_block(&self, _block: &mut ExecutedBlock) {}
|
||||||
|
|
||||||
/// If Some(true) this author is able to generate seals, generate_seal has to be implemented.
|
/// If Some(true) this author is able to generate seals, generate_seal has to be implemented.
|
||||||
/// None indicates that this engine does not seal internally regardless of author (e.g. PoW).
|
/// None indicates that this Engine never seals internally regardless of author (e.g. PoW).
|
||||||
fn is_sealer(&self, _author: &Address) -> Option<bool> { None }
|
fn is_sealer(&self, _author: &Address) -> Option<bool> { None }
|
||||||
|
/// Checks if default address is able to seal.
|
||||||
|
fn is_default_sealer(&self) -> Option<bool> { self.is_sealer(&Default::default()) }
|
||||||
/// Attempt to seal the block internally.
|
/// Attempt to seal the block internally.
|
||||||
///
|
///
|
||||||
/// If `Some` is returned, then you get a valid seal.
|
/// If `Some` is returned, then you get a valid seal.
|
||||||
|
@ -190,8 +190,6 @@ pub struct Miner {
|
|||||||
impl Miner {
|
impl Miner {
|
||||||
/// Creates new instance of miner without accounts, but with given spec.
|
/// Creates new instance of miner without accounts, but with given spec.
|
||||||
pub fn with_spec(spec: &Spec) -> Miner {
|
pub fn with_spec(spec: &Spec) -> Miner {
|
||||||
let author = Address::default();
|
|
||||||
let is_sealer = spec.engine.is_sealer(&author);
|
|
||||||
Miner {
|
Miner {
|
||||||
transaction_queue: Arc::new(Mutex::new(TransactionQueue::new())),
|
transaction_queue: Arc::new(Mutex::new(TransactionQueue::new())),
|
||||||
options: Default::default(),
|
options: Default::default(),
|
||||||
@ -199,11 +197,11 @@ impl Miner {
|
|||||||
sealing_block_last_request: Mutex::new(0),
|
sealing_block_last_request: Mutex::new(0),
|
||||||
sealing_work: Mutex::new(SealingWork{
|
sealing_work: Mutex::new(SealingWork{
|
||||||
queue: UsingQueue::new(20),
|
queue: UsingQueue::new(20),
|
||||||
enabled: is_sealer.unwrap_or(false)
|
enabled: spec.engine.is_default_sealer().unwrap_or(false)
|
||||||
}),
|
}),
|
||||||
seals_internally: is_sealer.is_some(),
|
seals_internally: spec.engine.is_default_sealer().is_some(),
|
||||||
gas_range_target: RwLock::new((U256::zero(), U256::zero())),
|
gas_range_target: RwLock::new((U256::zero(), U256::zero())),
|
||||||
author: RwLock::new(author),
|
author: RwLock::new(Address::default()),
|
||||||
extra_data: RwLock::new(Vec::new()),
|
extra_data: RwLock::new(Vec::new()),
|
||||||
accounts: None,
|
accounts: None,
|
||||||
engine: spec.engine.clone(),
|
engine: spec.engine.clone(),
|
||||||
@ -216,8 +214,6 @@ impl Miner {
|
|||||||
pub fn new(options: MinerOptions, gas_pricer: GasPricer, spec: &Spec, accounts: Option<Arc<AccountProvider>>) -> Arc<Miner> {
|
pub fn new(options: MinerOptions, gas_pricer: GasPricer, spec: &Spec, accounts: Option<Arc<AccountProvider>>) -> Arc<Miner> {
|
||||||
let work_poster = if !options.new_work_notify.is_empty() { Some(WorkPoster::new(&options.new_work_notify)) } else { None };
|
let work_poster = if !options.new_work_notify.is_empty() { Some(WorkPoster::new(&options.new_work_notify)) } else { None };
|
||||||
let txq = Arc::new(Mutex::new(TransactionQueue::with_limits(options.tx_queue_size, options.tx_gas_limit)));
|
let txq = Arc::new(Mutex::new(TransactionQueue::with_limits(options.tx_queue_size, options.tx_gas_limit)));
|
||||||
let author = Address::default();
|
|
||||||
let is_sealer = spec.engine.is_sealer(&author);
|
|
||||||
Arc::new(Miner {
|
Arc::new(Miner {
|
||||||
transaction_queue: txq,
|
transaction_queue: txq,
|
||||||
next_allowed_reseal: Mutex::new(Instant::now()),
|
next_allowed_reseal: Mutex::new(Instant::now()),
|
||||||
@ -226,11 +222,11 @@ impl Miner {
|
|||||||
queue: UsingQueue::new(options.work_queue_size),
|
queue: UsingQueue::new(options.work_queue_size),
|
||||||
enabled: options.force_sealing
|
enabled: options.force_sealing
|
||||||
|| !options.new_work_notify.is_empty()
|
|| !options.new_work_notify.is_empty()
|
||||||
|| is_sealer.unwrap_or(false)
|
|| spec.engine.is_default_sealer().unwrap_or(false)
|
||||||
}),
|
}),
|
||||||
seals_internally: is_sealer.is_some(),
|
seals_internally: spec.engine.is_default_sealer().is_some(),
|
||||||
gas_range_target: RwLock::new((U256::zero(), U256::zero())),
|
gas_range_target: RwLock::new((U256::zero(), U256::zero())),
|
||||||
author: RwLock::new(author),
|
author: RwLock::new(Address::default()),
|
||||||
extra_data: RwLock::new(Vec::new()),
|
extra_data: RwLock::new(Vec::new()),
|
||||||
options: options,
|
options: options,
|
||||||
accounts: accounts,
|
accounts: accounts,
|
||||||
|
Loading…
Reference in New Issue
Block a user