TransactionQueue::import accepts iterator (#10889)

This commit is contained in:
Marek Kotewicz 2019-07-16 12:46:13 +02:00 committed by Wei Tang
parent 27d1c2d7d1
commit c62e97d3c4
2 changed files with 5 additions and 6 deletions

View File

@ -950,7 +950,7 @@ impl miner::MinerService for Miner {
let client = self.pool_client(chain);
let results = self.transaction_queue.import(
client,
transactions.into_iter().map(pool::verifier::Transaction::Unverified).collect(),
transactions.into_iter().map(pool::verifier::Transaction::Unverified),
);
// --------------------------------------------------------------------------
@ -976,7 +976,7 @@ impl miner::MinerService for Miner {
let client = self.pool_client(chain);
let imported = self.transaction_queue.import(
client,
vec![pool::verifier::Transaction::Local(pending)]
Some(pool::verifier::Transaction::Local(pending))
).pop().expect("one result returned per added transaction; one added => one result; qed");
// --------------------------------------------------------------------------
@ -1376,8 +1376,7 @@ impl miner::MinerService for Miner {
.expect("Client is sending message after commit to db and inserting to chain; the block is available; qed");
let txs = block.transactions()
.into_iter()
.map(pool::verifier::Transaction::Retracted)
.collect();
.map(pool::verifier::Transaction::Retracted);
let _ = self.transaction_queue.import(
client.clone(),
txs,

View File

@ -241,10 +241,10 @@ impl TransactionQueue {
///
/// Given blockchain and state access (Client)
/// verifies and imports transactions to the pool.
pub fn import<C: client::Client + client::NonceClient + Clone>(
pub fn import<T: IntoIterator<Item = verifier::Transaction>, C: client::Client + client::NonceClient + Clone>(
&self,
client: C,
transactions: Vec<verifier::Transaction>,
transactions: T,
) -> Vec<Result<(), transaction::Error>> {
// Run verification
trace_time!("pool::verify_and_import");