Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions crates/esplora/src/async_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,29 @@ pub trait EsploraAsyncExt {
/// `stop_gap` script pubkeys with no associated transactions. `parallel_requests` specifies
/// the maximum number of HTTP requests to make in parallel.
///
/// # Example
///
/// ```no_run
/// use bdk_core::bitcoin::{constants, Network};
/// use bdk_core::spk_client::FullScanRequest;
/// use bdk_core::CheckPoint;
/// use bdk_esplora::{esplora_client, EsploraAsyncExt};
///
/// # async fn example() -> Result<(), bdk_esplora::Error> {
/// let client = esplora_client::Builder::new("https://blockstream.info/api").build_async()?;
///
/// let request = FullScanRequest::<&str>::builder()
/// .chain_tip(CheckPoint::new(
/// 0,
/// constants::genesis_block(Network::Bitcoin).block_hash(),
/// ))
/// .build();
///
/// let response = client.full_scan(request, 10, 5).await?;
/// # Ok(())
/// # }
/// ```
///
/// Refer to [crate-level docs](crate) for more.
async fn full_scan<K: Ord + Clone + Send, R: Into<FullScanRequest<K>> + Send>(
&self,
Expand All @@ -43,6 +66,25 @@ pub trait EsploraAsyncExt {
/// [`SyncRequest`]). `parallel_requests` specifies the maximum number of HTTP requests to make
/// in parallel.
///
/// # Example
///
/// ```no_run
/// use bdk_core::bitcoin::ScriptBuf;
/// use bdk_core::spk_client::SyncRequest;
/// use bdk_esplora::{esplora_client, EsploraAsyncExt};
///
/// # async fn example() -> Result<(), bdk_esplora::Error> {
/// let client = esplora_client::Builder::new("https://blockstream.info/api").build_async()?;
///
/// let request = SyncRequest::builder()
/// .spks([ScriptBuf::new_op_return(&[0x00; 20])])
/// .build();
///
/// let response = client.sync(request, 5).await?;
/// # Ok(())
/// # }
/// ```
///
/// Refer to [crate-level docs](crate) for more.
async fn sync<I: Send, R: Into<SyncRequest<I>> + Send>(
&self,
Expand Down
38 changes: 38 additions & 0 deletions crates/esplora/src/blocking_ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,27 @@ pub trait EsploraExt {
/// `stop_gap` script pubkeys with no associated transactions. `parallel_requests` specifies
/// the maximum number of HTTP requests to make in parallel.
///
/// # Example
///
/// ```no_run
/// use bdk_core::bitcoin::{constants, Network};
/// use bdk_core::spk_client::FullScanRequest;
/// use bdk_core::CheckPoint;
/// use bdk_esplora::{esplora_client, EsploraExt};
///
/// let client = esplora_client::Builder::new("https://blockstream.info/api").build_blocking();
///
/// let request = FullScanRequest::<&str>::builder()
/// .chain_tip(CheckPoint::new(
/// 0,
/// constants::genesis_block(Network::Bitcoin).block_hash(),
/// ))
/// .build();
///
/// let response = client.full_scan(request, 10, 5)?;
/// # Ok::<_, bdk_esplora::Error>(())
/// ```
///
/// Refer to [crate-level docs](crate) for more.
fn full_scan<K: Ord + Clone, R: Into<FullScanRequest<K>>>(
&self,
Expand All @@ -40,6 +61,23 @@ pub trait EsploraExt {
/// [`SyncRequest`]). `parallel_requests` specifies the maximum number of HTTP requests to make
/// in parallel.
///
/// # Example
///
/// ```no_run
/// use bdk_core::bitcoin::ScriptBuf;
/// use bdk_core::spk_client::SyncRequest;
/// use bdk_esplora::{esplora_client, EsploraExt};
///
/// let client = esplora_client::Builder::new("https://blockstream.info/api").build_blocking();
///
/// let request = SyncRequest::builder()
/// .spks([ScriptBuf::new_op_return(&[0x00; 20])])
/// .build();
///
/// let response = client.sync(request, 5)?;
/// # Ok::<_, bdk_esplora::Error>(())
/// ```
///
/// Refer to [crate-level docs](crate) for more.
fn sync<I: 'static, R: Into<SyncRequest<I>>>(
&self,
Expand Down