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

@@ -1,8 +1,9 @@
#![doc = include_str!("../README.md")]
use bdk_chain::ConfirmationTime;
use bdk_chain::{BlockId, ConfirmationTime, ConfirmationTimeAnchor};
use esplora_client::TxStatus;
pub use esplora_client;
pub mod v2;
#[cfg(feature = "blocking")]
mod blocking_ext;
@@ -25,3 +26,17 @@ pub(crate) fn map_confirmation_time(
_ => ConfirmationTime::Unconfirmed { last_seen: 0 },
}
}
pub(crate) fn map_confirmation_time_anchor(
tx_status: &TxStatus,
tip_at_start: BlockId,
) -> Option<ConfirmationTimeAnchor> {
match (tx_status.block_time, tx_status.block_height) {
(Some(confirmation_time), Some(confirmation_height)) => Some(ConfirmationTimeAnchor {
anchor_block: tip_at_start,
confirmation_height,
confirmation_time,
}),
_ => None,
}
}