poller: don't check spending status of expired coins

If the deposit tx itself isn't in mempool anymore, it's always going to
fail. Avoid needless work and error log.
This commit is contained in:
Antoine Poinsot 2023-11-17 10:45:38 +01:00
parent 0e5634ce59
commit 6daf7ac260
No known key found for this signature in database
GPG Key ID: E13FC145CD3F4304

View File

@ -5,6 +5,7 @@ use crate::{
};
use std::{
collections::HashSet,
sync::{self, atomic},
thread, time,
};
@ -114,15 +115,18 @@ fn update_coins(
// chain anymore.
// NOTE: curr_coins contain the "spending" coins. So this takes care of updating the spend_txid
// if a coin's spending transaction gets RBF'd.
let expired_set: HashSet<_> = expired.iter().collect();
let to_be_spent: Vec<bitcoin::OutPoint> = curr_coins
.values()
.chain(received.iter())
.filter_map(|coin| {
// Always check for spends when the spend tx is not confirmed as it might get RBF'd.
if coin.spend_txid.is_none() || coin.spend_block.is_none() {
Some(coin.outpoint)
} else {
if (coin.spend_txid.is_some() && coin.spend_block.is_some())
|| expired_set.contains(&coin.outpoint)
{
None
} else {
Some(coin.outpoint)
}
})
.collect();