Clean up some of the FP stuff.

This commit is contained in:
Gav Wood 2016-06-28 10:00:28 +02:00
parent 495e56034f
commit c221f69ccd
2 changed files with 6 additions and 5 deletions

View File

@ -496,7 +496,7 @@ impl MinerService for Miner {
};
match (&self.options.pending_set, sealing_set) {
(&PendingSet::AlwaysQueue, _) | (&PendingSet::SealingOrElseQueue, None) => queue.top_transactions(),
(_, sealing) => sealing.map(|s| s.transactions().clone()).unwrap_or(Vec::new()),
(_, sealing) => sealing.map_or_else(Vec::new, |s| s.transactions().clone()),
}
}
@ -509,7 +509,7 @@ impl MinerService for Miner {
};
match (&self.options.pending_set, sealing_set) {
(&PendingSet::AlwaysQueue, _) | (&PendingSet::SealingOrElseQueue, None) => queue.pending_hashes(),
(_, sealing) => sealing.map(|s| s.transactions().iter().map(|t| t.hash()).collect()).unwrap_or(Vec::new()),
(_, sealing) => sealing.map_or_else(Vec::new, |s| s.transactions().iter().map(|t| t.hash()).collect()),
}
}

View File

@ -459,10 +459,11 @@ impl TransactionQueue {
if tx.gas > self.gas_limit || self.tx_gas_limit.map(|l| tx.gas > l).unwrap_or(false) {
trace!(target: "miner",
"Dropping transaction above gas limit: {:?} ({} > {})",
"Dropping transaction above gas limit: {:?} ({} > min({}, {:?}))",
tx.hash(),
tx.gas,
self.gas_limit
self.gas_limit,
self.tx_gas_limit
);
return Err(Error::Transaction(TransactionError::GasLimitExceeded {
@ -606,7 +607,7 @@ impl TransactionQueue {
self.current.by_priority
.iter()
.map(|t| self.by_hash.get(&t.hash).expect("All transactions in `current` and `future` are always included in `by_hash`"))
.filter_map(|t| if &t.transaction.gas <= max_tx_gas { Some(t.transaction.clone()) } else { None })
.map(|t| &t.transaction).filter(|t| t.gas <= *max_tx_gas).cloned()
.collect()
}