pending_sync: false,
}
}
- pub fn sync_unconfirmed_transactions(
- &mut self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>,
+ pub fn sync_unconfirmed_transactions<C: Confirm>(
+ &mut self, confirmables: &Vec<C>,
unconfirmed_txs: Vec<Txid>,
) {
for txid in unconfirmed_txs {
}
}
- pub fn sync_confirmed_transactions(
- &mut self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>,
+ pub fn sync_confirmed_transactions<C: Confirm>(
+ &mut self, confirmables: &Vec<C>,
confirmed_txs: Vec<ConfirmedTx>
) {
for ctx in confirmed_txs {
+//! Chain sync using the electrum protocol
+
use crate::common::{ConfirmedTx, SyncState, FilterQueue};
use crate::error::{TxSyncError, InternalError};
/// [`ChainMonitor`]: lightning::chain::chainmonitor::ChainMonitor
/// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
/// [`Filter`]: lightning::chain::Filter
- pub fn sync(&self, confirmables: Vec<&(dyn Confirm + Sync + Send)>) -> Result<(), TxSyncError> {
+ pub fn sync<C: Confirm>(&self, confirmables: Vec<C>) -> Result<(), TxSyncError> {
// This lock makes sure we're syncing once at a time.
let mut sync_state = self.sync_state.lock().unwrap();
Ok(confirmed_txs)
}
- fn get_unconfirmed_transactions(
- &self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>,
+ fn get_unconfirmed_transactions<C: Confirm>(
+ &self, confirmables: &Vec<C>,
) -> Result<Vec<Txid>, InternalError> {
// Query the interface for relevant txids and check whether the relevant blocks are still
// in the best chain, mark them unconfirmed otherwise
+//! Common error types
+
use std::fmt;
#[derive(Debug)]
+//! Chain sync using the Esplora API
+
use crate::error::{TxSyncError, InternalError};
use crate::common::{SyncState, FilterQueue, ConfirmedTx};
/// [`ChannelManager`]: lightning::ln::channelmanager::ChannelManager
/// [`Filter`]: lightning::chain::Filter
#[maybe_async]
- pub fn sync(&self, confirmables: Vec<&(dyn Confirm + Sync + Send)>) -> Result<(), TxSyncError> {
+ pub fn sync<C: Confirm>(&self, confirmables: Vec<C>) -> Result<(), TxSyncError> {
// This lock makes sure we're syncing once at a time.
#[cfg(not(feature = "async-interface"))]
let mut sync_state = self.sync_state.lock().unwrap();
}
#[maybe_async]
- fn sync_best_block_updated(
- &self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>, sync_state: &mut SyncState, tip_hash: &BlockHash,
+ fn sync_best_block_updated<C: Confirm>(
+ &self, confirmables: &Vec<C>, sync_state: &mut SyncState, tip_hash: &BlockHash,
) -> Result<(), InternalError> {
// Inform the interface of the new block.
}
#[maybe_async]
- fn get_unconfirmed_transactions(
- &self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>,
+ fn get_unconfirmed_transactions<C: Confirm>(
+ &self, confirmables: &Vec<C>,
) -> Result<Vec<Txid>, InternalError> {
// Query the interface for relevant txids and check whether the relevant blocks are still
// in the best chain, mark them unconfirmed otherwise
extern crate bdk_macros;
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))]
-mod esplora;
+pub mod esplora;
#[cfg(any(feature = "electrum"))]
-mod electrum;
+pub mod electrum;
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "electrum"))]
mod common;
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "electrum"))]
-mod error;
+pub mod error;
#[cfg(any(feature = "esplora-blocking", feature = "esplora-async", feature = "electrum"))]
pub use error::TxSyncError;