1
0
mirror of https://github.com/romanz/electrs.git synced 2024-11-19 09:54:09 +01:00

Refactor Status::sync_confirmed a bit

This commit is contained in:
Roman Zeyde 2021-11-05 08:40:53 +02:00
parent 2228c4e4a6
commit a73866297f

View File

@ -343,16 +343,15 @@ impl ScriptHashStatus {
return None; return None;
} }
cache.add_tx(*txid, move || tx); cache.add_tx(*txid, move || tx);
cache.add_proof(blockhash, *txid, || Proof::create(&funding_txids, pos));
Some((pos, txid, funding_outputs)) Some((pos, txid, funding_outputs))
}) })
.collect(); .collect();
let block_entries = result.entry(blockhash).or_default();
for (pos, txid, funding_outputs) in found { for (pos, txid, funding_outputs) in found {
cache.add_proof(blockhash, *txid, || Proof::create(&funding_txids, pos));
outpoints.extend(make_outpoints(txid, &funding_outputs)); outpoints.extend(make_outpoints(txid, &funding_outputs));
result block_entries
.entry(blockhash)
.or_default()
.entry(pos) .entry(pos)
.or_insert_with(|| TxEntry::new(*txid)) .or_insert_with(|| TxEntry::new(*txid))
.outputs = funding_outputs; .outputs = funding_outputs;
@ -375,15 +374,14 @@ impl ScriptHashStatus {
return None; return None;
} }
cache.add_tx(*txid, move || tx); cache.add_tx(*txid, move || tx);
cache.add_proof(blockhash, *txid, || Proof::create(&spending_txids, pos));
Some((pos, txid, spent_outpoints)) Some((pos, txid, spent_outpoints))
}) })
.collect(); .collect();
let block_entries = result.entry(blockhash).or_default();
for (pos, txid, spent_outpoints) in found { for (pos, txid, spent_outpoints) in found {
cache.add_proof(blockhash, *txid, || Proof::create(&spending_txids, pos)); block_entries
result
.entry(blockhash)
.or_default()
.entry(pos) .entry(pos)
.or_insert_with(|| TxEntry::new(*txid)) .or_insert_with(|| TxEntry::new(*txid))
.spent = spent_outpoints; .spent = spent_outpoints;