use bitcoin::block::Header;
use std::collections::{HashSet, HashMap};
+use std::ops::Deref;
// Represents the current state.
pending_sync: false,
}
}
- pub fn sync_unconfirmed_transactions(
- &mut self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>,
+ pub fn sync_unconfirmed_transactions<C: Deref>(
+ &mut self, confirmables: &Vec<C>,
unconfirmed_txs: Vec<Txid>,
- ) {
+ )
+ where C::Target: Confirm,
+ {
for txid in unconfirmed_txs {
for c in confirmables {
c.transaction_unconfirmed(&txid);
}
}
- pub fn sync_confirmed_transactions(
- &mut self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>,
+ pub fn sync_confirmed_transactions<C: Deref>(
+ &mut self, confirmables: &Vec<C>,
confirmed_txs: Vec<ConfirmedTx>
- ) {
+ )
+ where C::Target: Confirm,
+ {
for ctx in confirmed_txs {
for c in confirmables {
c.transactions_confirmed(
/// [`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: Deref>(&self, confirmables: Vec<C>) -> Result<(), TxSyncError>
+ where C::Target: Confirm
+ {
// 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)>,
- ) -> Result<Vec<Txid>, InternalError> {
+ fn get_unconfirmed_transactions<C: Deref>(
+ &self, confirmables: &Vec<C>,
+ ) -> Result<Vec<Txid>, InternalError>
+ where C::Target: Confirm
+ {
// Query the interface for relevant txids and check whether the relevant blocks are still
// in the best chain, mark them unconfirmed otherwise
let relevant_txids = confirmables
/// [`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: Deref>(&self, confirmables: Vec<C>) -> Result<(), TxSyncError>
+ where C::Target: Confirm
+ {
// 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,
- ) -> Result<(), InternalError> {
-
+ fn sync_best_block_updated<C: Deref>(
+ &self, confirmables: &Vec<C>, sync_state: &mut SyncState, tip_hash: &BlockHash,
+ ) -> Result<(), InternalError>
+ where C::Target: Confirm
+ {
// Inform the interface of the new block.
let tip_header = maybe_await!(self.client.get_header_by_hash(tip_hash))?;
let tip_status = maybe_await!(self.client.get_block_status(&tip_hash))?;
}
#[maybe_async]
- fn get_unconfirmed_transactions(
- &self, confirmables: &Vec<&(dyn Confirm + Sync + Send)>,
- ) -> Result<Vec<Txid>, InternalError> {
+ fn get_unconfirmed_transactions<C: Deref>(
+ &self, confirmables: &Vec<C>,
+ ) -> Result<Vec<Txid>, InternalError>
+ where C::Target: Confirm
+ {
// Query the interface for relevant txids and check whether the relevant blocks are still
// in the best chain, mark them unconfirmed otherwise
let relevant_txids = confirmables