fix(provider): fix sub overflow on tx_range queries for empty blocks (#11568)

This commit is contained in:
joshieDo
2024-10-08 21:54:47 +09:00
committed by GitHub
parent cb431f1f5c
commit 65e6683295

View File

@ -463,8 +463,9 @@ impl<N: ProviderNodeTypes> BlockchainProvider2<N> {
let block_tx_count = block_state.block_ref().block().body.transactions.len(); let block_tx_count = block_state.block_ref().block().body.transactions.len();
let remaining = (tx_range.end() - tx_range.start() + 1) as usize; let remaining = (tx_range.end() - tx_range.start() + 1) as usize;
// If the transaction range start is higher than this block last transaction, advance // If the transaction range start is equal or higher than the next block first
if *tx_range.start() > in_memory_tx_num + block_tx_count as u64 - 1 { // transaction, advance
if *tx_range.start() >= in_memory_tx_num + block_tx_count as u64 {
in_memory_tx_num += block_tx_count as u64; in_memory_tx_num += block_tx_count as u64;
continue continue
} }