Quick fix: Cap history to 1000x utxo limit

This commit is contained in:
junderw 2026-04-16 23:15:36 +09:00
parent 51fd37d553
commit 1e09101c5e
No known key found for this signature in database
GPG Key ID: B256185D3A971908

View File

@ -997,6 +997,12 @@ impl ChainQuery {
let mut processed_items = 0;
let mut lastblock = None;
// If we need to iterate over 500 history entries to
// get one utxo then your address is too active and should be
// throttled.
// TODO: Think of better way to throttle.
let tx_history_limit = limit * 500;
for (history, blockid) in history_iter {
processed_items += 1;
lastblock = Some(blockid.hash);
@ -1017,6 +1023,9 @@ impl ChainQuery {
if utxos.len() > limit {
bail!(ErrorKind::TooManyUtxos(limit))
}
if processed_items > tx_history_limit {
bail!(ErrorKind::TooManyTxs(tx_history_limit))
}
}
Ok((utxos, lastblock, processed_items))