Struct bdk_chain::spk_client::SyncRequest
source · pub struct SyncRequest {
pub chain_tip: CheckPoint,
pub tx_cache: TxCache,
pub spks: Box<dyn ExactSizeIterator<Item = ScriptBuf> + Send>,
pub txids: Box<dyn ExactSizeIterator<Item = Txid> + Send>,
pub outpoints: Box<dyn ExactSizeIterator<Item = OutPoint> + Send>,
}
Expand description
Data required to perform a spk-based blockchain client sync.
A client sync fetches relevant chain data for a known list of scripts, transaction ids and
outpoints. The sync process also updates the chain from the given CheckPoint
.
Fields§
§chain_tip: CheckPoint
A checkpoint for the current chain LocalChain::tip
.
The sync process will return a new chain update that extends this tip.
tx_cache: TxCache
Cache of full transactions, so the chain-source can avoid re-fetching.
spks: Box<dyn ExactSizeIterator<Item = ScriptBuf> + Send>
Transactions that spend from or to these indexed script pubkeys.
txids: Box<dyn ExactSizeIterator<Item = Txid> + Send>
Transactions with these txids.
outpoints: Box<dyn ExactSizeIterator<Item = OutPoint> + Send>
Transactions with these outpoints or spent from these outpoints.
Implementations§
source§impl SyncRequest
impl SyncRequest
sourcepub fn from_chain_tip(cp: CheckPoint) -> Self
pub fn from_chain_tip(cp: CheckPoint) -> Self
Construct a new SyncRequest
from a given cp
tip.
sourcepub fn cache_txs<T>(self, full_txs: impl IntoIterator<Item = (Txid, T)>) -> Selfwhere
T: Into<Arc<Transaction>>,
pub fn cache_txs<T>(self, full_txs: impl IntoIterator<Item = (Txid, T)>) -> Selfwhere
T: Into<Arc<Transaction>>,
Add to the TxCache
held by the request.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn cache_graph_txs<A>(self, graph: &TxGraph<A>) -> Self
pub fn cache_graph_txs<A>(self, graph: &TxGraph<A>) -> Self
Add all transactions from TxGraph
into the TxCache
.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn set_spks(
self,
spks: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = ScriptBuf> + Send + 'static>
) -> Self
pub fn set_spks(
self,
spks: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = ScriptBuf> + Send + 'static>
) -> Self
Set the [Script
]s that will be synced against.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn set_txids(
self,
txids: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = Txid> + Send + 'static>
) -> Self
pub fn set_txids(
self,
txids: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = Txid> + Send + 'static>
) -> Self
Set the [Txid
]s that will be synced against.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn set_outpoints(
self,
outpoints: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = OutPoint> + Send + 'static>
) -> Self
pub fn set_outpoints(
self,
outpoints: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = OutPoint> + Send + 'static>
) -> Self
Set the [OutPoint
]s that will be synced against.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn chain_spks(
self,
spks: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = ScriptBuf> + Send + 'static, Item = ScriptBuf>
) -> Self
pub fn chain_spks(
self,
spks: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = ScriptBuf> + Send + 'static, Item = ScriptBuf>
) -> Self
Chain on additional [Script
]s that will be synced against.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn chain_txids(
self,
txids: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = Txid> + Send + 'static, Item = Txid>
) -> Self
pub fn chain_txids(
self,
txids: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = Txid> + Send + 'static, Item = Txid>
) -> Self
Chain on additional [Txid
]s that will be synced against.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn chain_outpoints(
self,
outpoints: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = OutPoint> + Send + 'static, Item = OutPoint>
) -> Self
pub fn chain_outpoints(
self,
outpoints: impl IntoIterator<IntoIter = impl ExactSizeIterator<Item = OutPoint> + Send + 'static, Item = OutPoint>
) -> Self
Chain on additional [OutPoint
]s that will be synced against.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn inspect_spks(
self,
inspect: impl FnMut(&Script) + Send + Sync + 'static
) -> Self
pub fn inspect_spks(
self,
inspect: impl FnMut(&Script) + Send + Sync + 'static
) -> Self
Add a closure that will be called for [Script
]s previously added to this request.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn inspect_txids(
self,
inspect: impl FnMut(&Txid) + Send + Sync + 'static
) -> Self
pub fn inspect_txids(
self,
inspect: impl FnMut(&Txid) + Send + Sync + 'static
) -> Self
Add a closure that will be called for [Txid
]s previously added to this request.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn inspect_outpoints(
self,
inspect: impl FnMut(&OutPoint) + Send + Sync + 'static
) -> Self
pub fn inspect_outpoints(
self,
inspect: impl FnMut(&OutPoint) + Send + Sync + 'static
) -> Self
Add a closure that will be called for [OutPoint
]s previously added to this request.
This consumes the SyncRequest
and returns the updated one.
sourcepub fn populate_with_revealed_spks<K: Clone + Ord + Debug + Send + Sync>(
self,
index: &KeychainTxOutIndex<K>,
spk_range: impl RangeBounds<K>
) -> Self
pub fn populate_with_revealed_spks<K: Clone + Ord + Debug + Send + Sync>(
self,
index: &KeychainTxOutIndex<K>,
spk_range: impl RangeBounds<K>
) -> Self
Populate the request with revealed script pubkeys from index
with the given spk_range
.
This consumes the SyncRequest
and returns the updated one.