pub struct Miner { /* private fields */ }
Expand description
Keeps track of transactions using priority queue and holds currently mined block. Handles preparing work for “work sealing” or seals “internally” if Engine does not require work.
Implementations
sourceimpl Miner
impl Miner
sourcepub fn add_work_listener(&self, notifier: Box<dyn NotifyWork>)
pub fn add_work_listener(&self, notifier: Box<dyn NotifyWork>)
Push listener that will handle new jobs
sourcepub fn add_transactions_listener(&self, f: Box<dyn Fn(&[H256]) + Send + Sync>)
pub fn add_transactions_listener(&self, f: Box<dyn Fn(&[H256]) + Send + Sync>)
Set a callback to be notified about imported transactions’ hashes.
sourcepub fn new<A: LocalAccounts + 'static>(
options: MinerOptions,
gas_pricer: GasPricer,
spec: &Spec,
accounts: A
) -> Self
pub fn new<A: LocalAccounts + 'static>(
options: MinerOptions,
gas_pricer: GasPricer,
spec: &Spec,
accounts: A
) -> Self
Creates new instance of miner Arc.
sourcepub fn new_for_tests(spec: &Spec, accounts: Option<HashSet<Address>>) -> Miner
pub fn new_for_tests(spec: &Spec, accounts: Option<HashSet<Address>>) -> Miner
Creates new instance of miner with given spec and accounts.
NOTE This should be only used for tests.
sourcepub fn new_for_tests_force_sealing(
spec: &Spec,
accounts: Option<HashSet<Address>>,
force_sealing: bool
) -> Miner
pub fn new_for_tests_force_sealing(
spec: &Spec,
accounts: Option<HashSet<Address>>,
force_sealing: bool
) -> Miner
Creates new instance of miner with given spec and accounts.
NOTE This should be only used for tests.
sourcepub fn set_io_channel(&self, io_channel: IoChannel<ClientIoMessage>)
pub fn set_io_channel(&self, io_channel: IoChannel<ClientIoMessage>)
Sets IoChannel
sourcepub fn set_in_chain_checker<C>(&self, chain: &Arc<C>) where
C: TransactionInfo + Send + Sync + 'static,
pub fn set_in_chain_checker<C>(&self, chain: &Arc<C>) where
C: TransactionInfo + Send + Sync + 'static,
Sets in-blockchain checker for transactions.
sourcepub fn update_transaction_queue_limits(
&self,
block_gas_limit: U256,
block_base_fee: Option<U256>,
allow_non_eoa_sender: bool
)
pub fn update_transaction_queue_limits(
&self,
block_gas_limit: U256,
block_base_fee: Option<U256>,
allow_non_eoa_sender: bool
)
Updates transaction queue verification limits.
Limits consist of current block gas limit and minimal gas price.
sourcepub fn service_transaction_checker(&self) -> Option<ServiceTransactionChecker>
pub fn service_transaction_checker(&self) -> Option<ServiceTransactionChecker>
Returns ServiceTransactionChecker
Trait Implementations
sourceimpl MinerService for Miner
impl MinerService for Miner
sourcefn update_sealing<C>(&self, chain: &C, force: ForceUpdateSealing) where
C: BlockChain + CallContract + BlockProducer + SealedBlockImporter + Nonce + Sync,
fn update_sealing<C>(&self, chain: &C, force: ForceUpdateSealing) where
C: BlockChain + CallContract + BlockProducer + SealedBlockImporter + Nonce + Sync,
Prepare the block and work if the Engine does not seal internally.
Get current authoring parameters.
sourcefn set_gas_range_target(&self, gas_range_target: (U256, U256))
fn set_gas_range_target(&self, gas_range_target: (U256, U256))
Set the lower and upper bound of gas limit we wish to target when sealing a new block.
sourcefn set_extra_data(&self, extra_data: Bytes)
fn set_extra_data(&self, extra_data: Bytes)
Set the extra_data that we will seal blocks with.
Set info necessary to sign consensus messages and block authoring. Read more
sourcefn sensible_gas_price(&self) -> U256
fn sensible_gas_price(&self) -> U256
Suggested gas price.
sourcefn sensible_max_priority_fee(&self) -> U256
fn sensible_max_priority_fee(&self) -> U256
Suggested max priority fee gas price
sourcefn sensible_gas_limit(&self) -> U256
fn sensible_gas_limit(&self) -> U256
Suggested gas limit.
sourcefn set_minimal_gas_price(&self, new_price: U256) -> Result<bool, &str>
fn set_minimal_gas_price(&self, new_price: U256) -> Result<bool, &str>
Set a new minimum gas limit. Will not work if dynamic gas calibration is set. Read more
sourcefn import_external_transactions<C: BlockChainClient>(
&self,
chain: &C,
transactions: Vec<UnverifiedTransaction>
) -> Vec<Result<(), Error>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn import_external_transactions<C: BlockChainClient>(
&self,
chain: &C,
transactions: Vec<UnverifiedTransaction>
) -> Vec<Result<(), Error>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Imports transactions to transaction queue.
sourcefn import_own_transaction<C: BlockChainClient>(
&self,
chain: &C,
pending: PendingTransaction
) -> Result<(), Error>
fn import_own_transaction<C: BlockChainClient>(
&self,
chain: &C,
pending: PendingTransaction
) -> Result<(), Error>
Imports own (node owner) transaction to queue.
sourcefn import_claimed_local_transaction<C: BlockChainClient>(
&self,
chain: &C,
pending: PendingTransaction,
trusted: bool
) -> Result<(), Error>
fn import_claimed_local_transaction<C: BlockChainClient>(
&self,
chain: &C,
pending: PendingTransaction,
trusted: bool
) -> Result<(), Error>
Imports transactions from potentially external sources, with behaviour determined
by the config flag tx_queue_allow_unfamiliar_locals
Read more
sourcefn local_transactions(&self) -> BTreeMap<H256, Status>
fn local_transactions(&self) -> BTreeMap<H256, Status>
Get a list of local transactions with statuses.
sourcefn queued_transactions(&self) -> Vec<Arc<VerifiedTransaction>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn queued_transactions(&self) -> Vec<Arc<VerifiedTransaction>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get a list of all transactions in the pool (some of them might not be ready for inclusion yet).
sourcefn queued_transaction_hashes(&self) -> Vec<H256>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
fn queued_transaction_hashes(&self) -> Vec<H256>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Get a list of all transaction hashes in the pool (some of them might not be ready for inclusion yet).
sourcefn pending_transaction_hashes<C>(&self, chain: &C) -> BTreeSet<H256> where
C: ChainInfo + Sync,
fn pending_transaction_hashes<C>(&self, chain: &C) -> BTreeSet<H256> where
C: ChainInfo + Sync,
Get a set of all pending transaction hashes. Read more
sourcefn ready_transactions_filtered<C>(
&self,
chain: &C,
max_len: usize,
filter: Option<TransactionFilter>,
ordering: PendingOrdering
) -> Vec<Arc<VerifiedTransaction>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
C: BlockChain + Nonce + Sync,
fn ready_transactions_filtered<C>(
&self,
chain: &C,
max_len: usize,
filter: Option<TransactionFilter>,
ordering: PendingOrdering
) -> Vec<Arc<VerifiedTransaction>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
C: BlockChain + Nonce + Sync,
A: Allocator,
Get a list of all ready transactions either ordered by priority or unordered (cheaper), and optionally filtered by sender, recipient, gas, gas price, value and/or nonce. Read more
sourcefn next_nonce<C>(&self, chain: &C, address: &Address) -> U256 where
C: Nonce + Sync,
fn next_nonce<C>(&self, chain: &C, address: &Address) -> U256 where
C: Nonce + Sync,
Returns next valid nonce for given address. Read more
sourcefn transaction(&self, hash: &H256) -> Option<Arc<VerifiedTransaction>>
fn transaction(&self, hash: &H256) -> Option<Arc<VerifiedTransaction>>
Query transaction from the pool given it’s hash.
sourcefn remove_transaction(&self, hash: &H256) -> Option<Arc<VerifiedTransaction>>
fn remove_transaction(&self, hash: &H256) -> Option<Arc<VerifiedTransaction>>
Removes transaction from the pool. Read more
sourcefn queue_status(&self) -> QueueStatus
fn queue_status(&self) -> QueueStatus
Get current queue status. Read more
sourcefn pending_receipts(&self, best_block: BlockNumber) -> Option<Vec<RichReceipt>>
fn pending_receipts(&self, best_block: BlockNumber) -> Option<Vec<RichReceipt>>
Get a list of all pending receipts from pending block.
sourcefn is_currently_sealing(&self) -> bool
fn is_currently_sealing(&self) -> bool
Is it currently sealing?
sourcefn work_package<C>(&self, chain: &C) -> Option<(H256, BlockNumber, u64, U256)> where
C: BlockChain + CallContract + BlockProducer + SealedBlockImporter + Nonce + Sync,
fn work_package<C>(&self, chain: &C) -> Option<(H256, BlockNumber, u64, U256)> where
C: BlockChain + CallContract + BlockProducer + SealedBlockImporter + Nonce + Sync,
Get the sealing work package preparing it if doesn’t exist yet. Read more
sourcefn submit_seal(
&self,
block_hash: H256,
seal: Vec<Bytes>
) -> Result<SealedBlock, Error>
fn submit_seal(
&self,
block_hash: H256,
seal: Vec<Bytes>
) -> Result<SealedBlock, Error>
Submit seal
as a valid solution for the header of pow_hash
.
Will check the seal, but not actually insert the block into the chain. Read more
sourcefn chain_new_blocks<C>(
&self,
chain: &C,
imported: &[H256],
_invalid: &[H256],
enacted: &[H256],
retracted: &[H256],
is_internal_import: bool
) where
C: BlockChainClient,
fn chain_new_blocks<C>(
&self,
chain: &C,
imported: &[H256],
_invalid: &[H256],
enacted: &[H256],
retracted: &[H256],
is_internal_import: bool
) where
C: BlockChainClient,
Called when blocks are imported to chain, updates transactions queue.
is_internal_import
indicates that the block has just been created in miner and internally sealed by the engine,
so we shouldn’t attempt creating new block again. Read more
sourcefn pending_state(&self, latest_block_number: BlockNumber) -> Option<Self::State>
fn pending_state(&self, latest_block_number: BlockNumber) -> Option<Self::State>
Get Some
clone()
of the current pending block’s state or None
if we’re not sealing.
sourcefn pending_block_header(
&self,
latest_block_number: BlockNumber
) -> Option<Header>
fn pending_block_header(
&self,
latest_block_number: BlockNumber
) -> Option<Header>
Get Some
clone()
of the current pending block header or None
if we’re not sealing.
sourcefn pending_block(&self, latest_block_number: BlockNumber) -> Option<Block>
fn pending_block(&self, latest_block_number: BlockNumber) -> Option<Block>
Get Some
clone()
of the current pending block or None
if we’re not sealing.
sourcefn pending_transactions(
&self,
latest_block_number: BlockNumber
) -> Option<Vec<SignedTransaction>>
fn pending_transactions(
&self,
latest_block_number: BlockNumber
) -> Option<Vec<SignedTransaction>>
Get Some
clone()
of the current pending block transactions or None
if we’re not sealing.
sourcefn pending_receipt(
&self,
best_block: BlockNumber,
hash: &H256
) -> Option<RichReceipt>
fn pending_receipt(
&self,
best_block: BlockNumber,
hash: &H256
) -> Option<RichReceipt>
Get a particular receipt from pending block.
sourcefn ready_transactions<C>(
&self,
chain: &C,
max_len: usize,
ordering: PendingOrdering
) -> Vec<Arc<VerifiedTransaction>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
C: BlockChain + Nonce + Sync,
fn ready_transactions<C>(
&self,
chain: &C,
max_len: usize,
ordering: PendingOrdering
) -> Vec<Arc<VerifiedTransaction>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
C: BlockChain + Nonce + Sync,
A: Allocator,
Get an unfiltered list of all ready transactions.
Auto Trait Implementations
impl !RefUnwindSafe for Miner
impl Send for Miner
impl Sync for Miner
impl Unpin for Miner
impl !UnwindSafe for Miner
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more