Struct bdk_chain::indexed_tx_graph::IndexedTxGraph
source · pub struct IndexedTxGraph<A, I> {
pub index: I,
/* private fields */
}
Expand description
The IndexedTxGraph
combines a TxGraph
and an Indexer
implementation.
Fields§
§index: I
Transaction index.
Implementations§
source§impl<A, I> IndexedTxGraph<A, I>
impl<A, I> IndexedTxGraph<A, I>
source§impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I>
impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I>
sourcepub fn apply_changeset(&mut self, changeset: ChangeSet<A, I::ChangeSet>)
pub fn apply_changeset(&mut self, changeset: ChangeSet<A, I::ChangeSet>)
Applies the ChangeSet
to the IndexedTxGraph
.
sourcepub fn initial_changeset(&self) -> ChangeSet<A, I::ChangeSet>
pub fn initial_changeset(&self) -> ChangeSet<A, I::ChangeSet>
Determines the ChangeSet
between self
and an empty IndexedTxGraph
.
source§impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I>where
I::ChangeSet: Default + Append,
impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I>where
I::ChangeSet: Default + Append,
sourcepub fn apply_update(&mut self, update: TxGraph<A>) -> ChangeSet<A, I::ChangeSet>
pub fn apply_update(&mut self, update: TxGraph<A>) -> ChangeSet<A, I::ChangeSet>
Apply an update
directly.
update
is a TxGraph<A>
and the resultant changes is returned as ChangeSet
.
sourcepub fn insert_txout(
&mut self,
outpoint: OutPoint,
txout: TxOut
) -> ChangeSet<A, I::ChangeSet>
pub fn insert_txout(
&mut self,
outpoint: OutPoint,
txout: TxOut
) -> ChangeSet<A, I::ChangeSet>
Insert a floating txout
of given outpoint
.
sourcepub fn insert_tx(&mut self, tx: Transaction) -> ChangeSet<A, I::ChangeSet>
pub fn insert_tx(&mut self, tx: Transaction) -> ChangeSet<A, I::ChangeSet>
Insert and index a transaction into the graph.
sourcepub fn insert_anchor(
&mut self,
txid: Txid,
anchor: A
) -> ChangeSet<A, I::ChangeSet>
pub fn insert_anchor(
&mut self,
txid: Txid,
anchor: A
) -> ChangeSet<A, I::ChangeSet>
Insert an anchor
for a given transaction.
sourcepub fn insert_seen_at(
&mut self,
txid: Txid,
seen_at: u64
) -> ChangeSet<A, I::ChangeSet>
pub fn insert_seen_at(
&mut self,
txid: Txid,
seen_at: u64
) -> ChangeSet<A, I::ChangeSet>
Insert a unix timestamp of when a transaction is seen in the mempool.
This is used for transaction conflict resolution in TxGraph
where the transaction with
the later last-seen is prioritized.
sourcepub fn batch_insert_relevant<'t>(
&mut self,
txs: impl IntoIterator<Item = (&'t Transaction, impl IntoIterator<Item = A>)>
) -> ChangeSet<A, I::ChangeSet>
pub fn batch_insert_relevant<'t>(
&mut self,
txs: impl IntoIterator<Item = (&'t Transaction, impl IntoIterator<Item = A>)>
) -> ChangeSet<A, I::ChangeSet>
Batch insert transactions, filtering out those that are irrelevant.
Relevancy is determined by the Indexer::is_tx_relevant
implementation of I
. Irrelevant
transactions in txs
will be ignored. txs
do not need to be in topological order.
sourcepub fn batch_insert_relevant_unconfirmed<'t>(
&mut self,
unconfirmed_txs: impl IntoIterator<Item = (&'t Transaction, u64)>
) -> ChangeSet<A, I::ChangeSet>
pub fn batch_insert_relevant_unconfirmed<'t>(
&mut self,
unconfirmed_txs: impl IntoIterator<Item = (&'t Transaction, u64)>
) -> ChangeSet<A, I::ChangeSet>
Batch insert unconfirmed transactions, filtering out those that are irrelevant.
Relevancy is determined by the internal Indexer::is_tx_relevant
implementation of I
.
Irrelevant transactions in txs
will be ignored.
Items of txs
are tuples containing the transaction and a last seen timestamp. The
last seen communicates when the transaction is last seen in the mempool which is used for
conflict-resolution in TxGraph
(refer to TxGraph::insert_seen_at
for details).
sourcepub fn batch_insert_unconfirmed(
&mut self,
txs: impl IntoIterator<Item = (Transaction, u64)>
) -> ChangeSet<A, I::ChangeSet>
pub fn batch_insert_unconfirmed(
&mut self,
txs: impl IntoIterator<Item = (Transaction, u64)>
) -> ChangeSet<A, I::ChangeSet>
Batch insert unconfirmed transactions.
Items of txs
are tuples containing the transaction and a last seen timestamp. The
last seen communicates when the transaction is last seen in the mempool which is used for
conflict-resolution in TxGraph
(refer to TxGraph::insert_seen_at
for details).
To filter out irrelevant transactions, use batch_insert_relevant_unconfirmed
instead.
source§impl<A, I: Indexer> IndexedTxGraph<A, I>where
I::ChangeSet: Default + Append,
A: AnchorFromBlockPosition + Anchor,
impl<A, I: Indexer> IndexedTxGraph<A, I>where
I::ChangeSet: Default + Append,
A: AnchorFromBlockPosition + Anchor,
Methods are available if the anchor (A
) implements AnchorFromBlockPosition
.
sourcepub fn apply_block_relevant(
&mut self,
block: &Block,
height: u32
) -> ChangeSet<A, I::ChangeSet>
pub fn apply_block_relevant(
&mut self,
block: &Block,
height: u32
) -> ChangeSet<A, I::ChangeSet>
Batch insert all transactions of the given block
of height
, filtering out those that are
irrelevant.
Each inserted transaction’s anchor will be constructed from
AnchorFromBlockPosition::from_block_position
.
Relevancy is determined by the internal Indexer::is_tx_relevant
implementation of I
.
Irrelevant transactions in txs
will be ignored.
sourcepub fn apply_block(
&mut self,
block: Block,
height: u32
) -> ChangeSet<A, I::ChangeSet>
pub fn apply_block(
&mut self,
block: Block,
height: u32
) -> ChangeSet<A, I::ChangeSet>
Batch insert all transactions of the given block
of height
.
Each inserted transaction’s anchor will be constructed from
AnchorFromBlockPosition::from_block_position
.
To only insert relevant transactions, use apply_block_relevant
instead.