refactor(electrum): remove RelevantTxids and track txs in TxGraph

This PR removes `RelevantTxids` from the electrum crate and tracks
transactions in a `TxGraph`. This removes the need to separately
construct a `TxGraph` after a `full_scan` or `sync`.
This commit is contained in:
Wei Chen
2024-04-11 17:57:14 -04:00
committed by 志宇
parent fb7ff298a4
commit 2ffb65618a
5 changed files with 160 additions and 186 deletions

View File

@@ -62,11 +62,16 @@ fn scan_detects_confirmed_tx() -> Result<()> {
env.wait_until_electrum_sees_block()?;
let ElectrumUpdate {
chain_update,
relevant_txids,
} = client.sync(recv_chain.tip(), [spk_to_track], None, None, 5)?;
graph_update,
} = client.sync::<ConfirmationTimeHeightAnchor>(
recv_chain.tip(),
[spk_to_track],
Some(recv_graph.graph()),
None,
None,
5,
)?;
let missing = relevant_txids.missing_full_txs(recv_graph.graph());
let graph_update = relevant_txids.into_confirmation_time_tx_graph(&client, missing)?;
let _ = recv_chain
.apply_update(chain_update)
.map_err(|err| anyhow::anyhow!("LocalChain update error: {:?}", err))?;
@@ -128,11 +133,16 @@ fn tx_can_become_unconfirmed_after_reorg() -> Result<()> {
env.wait_until_electrum_sees_block()?;
let ElectrumUpdate {
chain_update,
relevant_txids,
} = client.sync(recv_chain.tip(), [spk_to_track.clone()], None, None, 5)?;
graph_update,
} = client.sync::<ConfirmationTimeHeightAnchor>(
recv_chain.tip(),
[spk_to_track.clone()],
Some(recv_graph.graph()),
None,
None,
5,
)?;
let missing = relevant_txids.missing_full_txs(recv_graph.graph());
let graph_update = relevant_txids.into_confirmation_time_tx_graph(&client, missing)?;
let _ = recv_chain
.apply_update(chain_update)
.map_err(|err| anyhow::anyhow!("LocalChain update error: {:?}", err))?;
@@ -158,11 +168,16 @@ fn tx_can_become_unconfirmed_after_reorg() -> Result<()> {
env.wait_until_electrum_sees_block()?;
let ElectrumUpdate {
chain_update,
relevant_txids,
} = client.sync(recv_chain.tip(), [spk_to_track.clone()], None, None, 5)?;
graph_update,
} = client.sync::<ConfirmationTimeHeightAnchor>(
recv_chain.tip(),
[spk_to_track.clone()],
Some(recv_graph.graph()),
None,
None,
5,
)?;
let missing = relevant_txids.missing_full_txs(recv_graph.graph());
let graph_update = relevant_txids.into_confirmation_time_tx_graph(&client, missing)?;
let _ = recv_chain
.apply_update(chain_update)
.map_err(|err| anyhow::anyhow!("LocalChain update error: {:?}", err))?;