Fix potential as_usize overflow when casting from U256 in miner (#9221)

This commit is contained in:
Wei Tang 2018-07-27 18:07:46 +08:00 committed by André Silva
parent fb503f523b
commit 77a5ce6bf3

View File

@ -417,7 +417,7 @@ impl Miner {
let max_transactions = if min_tx_gas.is_zero() { let max_transactions = if min_tx_gas.is_zero() {
usize::max_value() usize::max_value()
} else { } else {
MAX_SKIPPED_TRANSACTIONS.saturating_add((*open_block.block().header().gas_limit() / min_tx_gas).as_u64() as usize) MAX_SKIPPED_TRANSACTIONS.saturating_add(cmp::min(*open_block.block().header().gas_limit() / min_tx_gas, u64::max_value().into()).as_u64() as usize)
}; };
let pending: Vec<Arc<_>> = self.transaction_queue.pending( let pending: Vec<Arc<_>> = self.transaction_queue.pending(