Fixing minimal transaction queue price (#4204)
* Fixing minimal transaction queue price * Fixing tests
This commit is contained in:
@@ -304,16 +304,6 @@ impl Miner {
|
||||
#[cfg_attr(feature="dev", allow(match_same_arms))]
|
||||
/// Prepares new block for sealing including top transactions from queue.
|
||||
fn prepare_block(&self, chain: &MiningBlockChainClient) -> (ClosedBlock, Option<H256>) {
|
||||
{
|
||||
trace!(target: "miner", "prepare_block: recalibrating...");
|
||||
let txq = self.transaction_queue.clone();
|
||||
self.gas_pricer.lock().recalibrate(move |price| {
|
||||
trace!(target: "miner", "prepare_block: Got gas price! {}", price);
|
||||
txq.lock().set_minimal_gas_price(price);
|
||||
});
|
||||
trace!(target: "miner", "prepare_block: done recalibration.");
|
||||
}
|
||||
|
||||
let _timer = PerfTimer::new("prepare_block");
|
||||
let chain_info = chain.chain_info();
|
||||
let (transactions, mut open_block, original_work_hash) = {
|
||||
@@ -428,6 +418,16 @@ impl Miner {
|
||||
(block, original_work_hash)
|
||||
}
|
||||
|
||||
/// Asynchronously updates minimal gas price for transaction queue
|
||||
pub fn recalibrate_minimal_gas_price(&self) {
|
||||
debug!(target: "miner", "minimal_gas_price: recalibrating...");
|
||||
let txq = self.transaction_queue.clone();
|
||||
self.gas_pricer.lock().recalibrate(move |price| {
|
||||
debug!(target: "miner", "minimal_gas_price: Got gas price! {}", price);
|
||||
txq.lock().set_minimal_gas_price(price);
|
||||
});
|
||||
}
|
||||
|
||||
/// Check is reseal is allowed and necessary.
|
||||
fn requires_reseal(&self, best_block: BlockNumber) -> bool {
|
||||
let has_local_transactions = self.transaction_queue.lock().has_local_pending_transactions();
|
||||
@@ -1121,6 +1121,9 @@ impl MinerService for Miner {
|
||||
// First update gas limit in transaction queue
|
||||
self.update_gas_limit(chain);
|
||||
|
||||
// Update minimal gas price
|
||||
self.recalibrate_minimal_gas_price();
|
||||
|
||||
// Then import all transactions...
|
||||
{
|
||||
retracted.par_iter()
|
||||
|
||||
Reference in New Issue
Block a user