checked_sub -> saturating_sub

This commit is contained in:
Svyatoslav Nikolsky 2017-12-27 15:21:31 +03:00
parent 2a73101fab
commit fc0eb600f3

View File

@ -301,7 +301,7 @@ impl Iterator for PendingRequestsIterator {
/// Get hash of the last block with at least n confirmations. /// Get hash of the last block with at least n confirmations.
fn get_confirmed_block_hash(client: &Client, confirmations: u64) -> Option<H256> { fn get_confirmed_block_hash(client: &Client, confirmations: u64) -> Option<H256> {
client.block_number(BlockId::Latest) client.block_number(BlockId::Latest)
.and_then(|b| b.checked_sub(confirmations)) .map(|b| b.saturating_sub(confirmations))
.and_then(|b| client.block_hash(BlockId::Number(b))) .and_then(|b| client.block_hash(BlockId::Number(b)))
} }