Implement redesigned versions of EsploraExt and EsploraAsyncExt

All associated examples are also updated.
This commit is contained in:
志宇
2023-05-18 14:04:48 +08:00
parent 2952341e52
commit 5860704b2d
9 changed files with 704 additions and 177 deletions

View File

@@ -82,7 +82,7 @@ impl EsploraExt for esplora_client::BlockingClient {
stop_gap: usize,
parallel_requests: usize,
) -> Result<KeychainScan<K, ConfirmationTime>, Error> {
let parallel_requests = parallel_requests.max(1);
let parallel_requests = Ord::max(parallel_requests, 1);
let mut scan = KeychainScan::default();
let update = &mut scan.update;
let last_active_indices = &mut scan.last_active_indices;
@@ -260,7 +260,7 @@ impl EsploraExt for esplora_client::BlockingClient {
}
let reorg_occurred = {
if let Some(checkpoint) = update.chain().latest_checkpoint() {
if let Some(checkpoint) = ChainGraph::chain(update).latest_checkpoint() {
self.get_block_hash(checkpoint.height)? != checkpoint.hash
} else {
false
@@ -270,8 +270,7 @@ impl EsploraExt for esplora_client::BlockingClient {
if reorg_occurred {
// A reorg occurred, so let's find out where all the txids we found are now in the chain.
// XXX: collect required because of weird type naming issues
let txids_found = update
.chain()
let txids_found = ChainGraph::chain(update)
.txids()
.map(|(_, txid)| *txid)
.collect::<Vec<_>>();