Update sealing on new transactions (#1365)
This commit is contained in:
parent
bca4e23df6
commit
b2891fcdda
@ -381,7 +381,7 @@ impl<V> Client<V> where V: Verifier {
|
|||||||
balance: self.latest_balance(a),
|
balance: self.latest_balance(a),
|
||||||
};
|
};
|
||||||
let tx = transactions.iter().filter_map(|bytes| UntrustedRlp::new(&bytes).as_val().ok()).collect();
|
let tx = transactions.iter().filter_map(|bytes| UntrustedRlp::new(&bytes).as_val().ok()).collect();
|
||||||
let results = self.miner.import_transactions(tx, fetch_account);
|
let results = self.miner.import_transactions(self, tx, fetch_account);
|
||||||
results.len()
|
results.len()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -771,7 +771,7 @@ impl<V> BlockChainClient for Client<V> where V: Verifier {
|
|||||||
nonce: self.latest_nonce(a),
|
nonce: self.latest_nonce(a),
|
||||||
balance: self.latest_balance(a),
|
balance: self.latest_balance(a),
|
||||||
};
|
};
|
||||||
self.miner.import_transactions(transactions, fetch_account)
|
self.miner.import_transactions(self, transactions, fetch_account)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn queue_transactions(&self, transactions: Vec<Bytes>) {
|
fn queue_transactions(&self, transactions: Vec<Bytes>) {
|
||||||
|
@ -490,7 +490,7 @@ impl BlockChainClient for TestBlockChainClient {
|
|||||||
balance: balances[a],
|
balance: balances[a],
|
||||||
};
|
};
|
||||||
|
|
||||||
self.miner.import_transactions(transactions, &fetch_account)
|
self.miner.import_transactions(self, transactions, &fetch_account)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn queue_transactions(&self, transactions: Vec<Bytes>) {
|
fn queue_transactions(&self, transactions: Vec<Bytes>) {
|
||||||
|
@ -376,13 +376,19 @@ impl MinerService for Miner {
|
|||||||
*self.gas_floor_target.read().unwrap()
|
*self.gas_floor_target.read().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) ->
|
fn import_transactions<T>(&self, chain: &MiningBlockChainClient, transactions: Vec<SignedTransaction>, fetch_account: T) ->
|
||||||
Vec<Result<TransactionImportResult, Error>>
|
Vec<Result<TransactionImportResult, Error>>
|
||||||
where T: Fn(&Address) -> AccountDetails {
|
where T: Fn(&Address) -> AccountDetails {
|
||||||
let mut transaction_queue = self.transaction_queue.lock().unwrap();
|
let results: Vec<Result<TransactionImportResult, Error>> = {
|
||||||
transactions.into_iter()
|
let mut transaction_queue = self.transaction_queue.lock().unwrap();
|
||||||
.map(|tx| transaction_queue.add(tx, &fetch_account, TransactionOrigin::External))
|
transactions.into_iter()
|
||||||
.collect()
|
.map(|tx| transaction_queue.add(tx, &fetch_account, TransactionOrigin::External))
|
||||||
|
.collect()
|
||||||
|
};
|
||||||
|
if !results.is_empty() {
|
||||||
|
self.update_sealing(chain);
|
||||||
|
}
|
||||||
|
results
|
||||||
}
|
}
|
||||||
|
|
||||||
fn import_own_transaction<T>(
|
fn import_own_transaction<T>(
|
||||||
@ -564,7 +570,7 @@ impl MinerService for Miner {
|
|||||||
for tx in &txs {
|
for tx in &txs {
|
||||||
let _sender = tx.sender();
|
let _sender = tx.sender();
|
||||||
}
|
}
|
||||||
let _ = self.import_transactions(txs, |a| AccountDetails {
|
let _ = self.import_transactions(chain, txs, |a| AccountDetails {
|
||||||
nonce: chain.latest_nonce(a),
|
nonce: chain.latest_nonce(a),
|
||||||
balance: chain.latest_balance(a),
|
balance: chain.latest_balance(a),
|
||||||
});
|
});
|
||||||
|
@ -94,7 +94,7 @@ pub trait MinerService : Send + Sync {
|
|||||||
fn set_transactions_limit(&self, limit: usize);
|
fn set_transactions_limit(&self, limit: usize);
|
||||||
|
|
||||||
/// Imports transactions to transaction queue.
|
/// Imports transactions to transaction queue.
|
||||||
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) ->
|
fn import_transactions<T>(&self, chain: &MiningBlockChainClient, transactions: Vec<SignedTransaction>, fetch_account: T) ->
|
||||||
Vec<Result<TransactionImportResult, Error>>
|
Vec<Result<TransactionImportResult, Error>>
|
||||||
where T: Fn(&Address) -> AccountDetails, Self: Sized;
|
where T: Fn(&Address) -> AccountDetails, Self: Sized;
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ impl MinerService for TestMinerService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Imports transactions to transaction queue.
|
/// Imports transactions to transaction queue.
|
||||||
fn import_transactions<T>(&self, transactions: Vec<SignedTransaction>, fetch_account: T) ->
|
fn import_transactions<T>(&self, _chain: &MiningBlockChainClient, transactions: Vec<SignedTransaction>, fetch_account: T) ->
|
||||||
Vec<Result<TransactionImportResult, Error>>
|
Vec<Result<TransactionImportResult, Error>>
|
||||||
where T: Fn(&Address) -> AccountDetails {
|
where T: Fn(&Address) -> AccountDetails {
|
||||||
// lets assume that all txs are valid
|
// lets assume that all txs are valid
|
||||||
|
Loading…
Reference in New Issue
Block a user