bdk_electrum API improvements and simplifications

* `ElectrumUpdate::missing_full_txs` now returns a `Vec<Txid>` so we
  don't keep a reference to the passed-in `graph`.

* `ElectrumUpdate::finalize*` methods now takes in `missing` txids
  instead of `full_txs`. `Client::batch_transaction_get` is called
within the methods.

Other changes:

* `wallet::ChangeSet` is now made public externally. This is required as
  a wallet db should implement `PersistBackend<wallet::ChangeSet>`.
This commit is contained in:
志宇
2023-05-18 10:02:23 +08:00
parent 92709d03ce
commit 78a7920ba3
3 changed files with 23 additions and 28 deletions

View File

@@ -278,20 +278,15 @@ fn main() -> anyhow::Result<()> {
let missing_txids = {
let graph = &*graph.lock().unwrap();
response
.missing_full_txs(graph.graph())
.cloned()
.collect::<Vec<_>>()
response.missing_full_txs(graph.graph())
};
let new_txs = client
.batch_transaction_get(&missing_txids)
.context("fetching full transactions")?;
let now = std::time::UNIX_EPOCH
.elapsed()
.expect("must get time")
.as_secs();
let final_update = response.finalize(Some(now), new_txs);
let final_update = response.finalize(&client, Some(now), missing_txids)?;
let db_changeset = {
let mut chain = chain.lock().unwrap();