Skip to content

Commit

Permalink
poller: only retrieve transactions once
Browse files Browse the repository at this point in the history
If we have already inserted a transaction into the DB, we do not
need to retrieve it again from the Bitcoin backend.
  • Loading branch information
jp1ac4 committed Jul 31, 2024
1 parent 780ad3b commit fb5767d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bitcoin/poller/looper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,13 @@ fn add_txs_to_db(
// Now retrieve txs.
let txs: Vec<_> = txids
.into_iter()
.map(|txid| bit.wallet_transaction(&txid).map(|(tx, _)| tx))
.filter_map(|txid| {
if db_conn.get_tx(&txid).is_none() {
Some(bit.wallet_transaction(&txid).map(|(tx, _)| tx))
} else {
None
}
})
.collect::<Option<Vec<_>>>()
.expect("we must retrieve all txs");
if !txs.is_empty() {
Expand Down

0 comments on commit fb5767d

Please sign in to comment.