pub type KeychainTxGraph = IndexedTxGraph<ConfirmationBlockTime, KeychainTxOutIndex<Keychain>>;
Expand description
Alias for a IndexedTxGraph
with specific Anchor
and Indexer
.
Aliased Type§
struct KeychainTxGraph {
pub index: KeychainTxOutIndex<Keychain>,
/* private fields */
}
Fields§
§index: KeychainTxOutIndex<Keychain>
Transaction index.
Implementations
§impl<A, I> IndexedTxGraph<A, I>
impl<A, I> IndexedTxGraph<A, I>
§impl<A, I> IndexedTxGraph<A, I>
Methods are available if the anchor (A
) can be created from [TxPosInBlock
].
impl<A, I> IndexedTxGraph<A, I>
Methods are available if the anchor (A
) can be created from [TxPosInBlock
].
pub fn apply_block_relevant(
&mut self,
block: &Block,
height: u32,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn apply_block_relevant( &mut self, block: &Block, height: u32, ) -> ChangeSet<A, <I as Indexer>::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 using [TxPosInBlock
].
Relevancy is determined by the internal [Indexer::is_tx_relevant
] implementation of I
.
Irrelevant transactions in txs
will be ignored.
pub fn apply_block(
&mut self,
block: Block,
height: u32,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn apply_block( &mut self, block: Block, height: u32, ) -> ChangeSet<A, <I as Indexer>::ChangeSet>
Batch insert all transactions of the given block
of height
.
Each inserted transaction’s anchor will be constructed using [TxPosInBlock
].
To only insert relevant transactions, use apply_block_relevant
instead.
§impl<A, I> IndexedTxGraph<A, I>where
A: Anchor,
I: Indexer,
impl<A, I> IndexedTxGraph<A, I>where
A: Anchor,
I: Indexer,
pub fn apply_changeset(
&mut self,
changeset: ChangeSet<A, <I as Indexer>::ChangeSet>,
)
pub fn apply_changeset( &mut self, changeset: ChangeSet<A, <I as Indexer>::ChangeSet>, )
Applies the [ChangeSet
] to the [IndexedTxGraph
].
pub fn initial_changeset(&self) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn initial_changeset(&self) -> ChangeSet<A, <I as Indexer>::ChangeSet>
Determines the [ChangeSet
] between self
and an empty [IndexedTxGraph
].
§impl<A, I> IndexedTxGraph<A, I>
impl<A, I> IndexedTxGraph<A, I>
pub fn apply_update(
&mut self,
update: TxUpdate<A>,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn apply_update( &mut self, update: TxUpdate<A>, ) -> ChangeSet<A, <I as Indexer>::ChangeSet>
Apply an update
directly.
update
is a tx_graph::TxUpdate<A>
and the resultant changes is returned as [ChangeSet
].
pub fn apply_update_at(
&mut self,
update: TxUpdate<A>,
seen_at: Option<u64>,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn apply_update_at( &mut self, update: TxUpdate<A>, seen_at: Option<u64>, ) -> ChangeSet<A, <I as Indexer>::ChangeSet>
Apply the given update
with an optional seen_at
timestamp.
seen_at
represents when the update is seen (in unix seconds). It is used to determine the
last_seen
s for all transactions in the update which have no corresponding anchor(s). The
last_seen
value is used internally to determine precedence of conflicting unconfirmed
transactions (where the transaction with the lower last_seen
value is omitted from the
canonical history).
Not setting a seen_at
value means unconfirmed transactions introduced by this update will
not be part of the canonical history of transactions.
Use apply_update
to have the seen_at
value automatically
set to the current time.
pub fn insert_txout(
&mut self,
outpoint: OutPoint,
txout: TxOut,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn insert_txout( &mut self, outpoint: OutPoint, txout: TxOut, ) -> ChangeSet<A, <I as Indexer>::ChangeSet>
Insert a floating txout
of given outpoint
.
pub fn insert_tx<T>(&mut self, tx: T) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn insert_tx<T>(&mut self, tx: T) -> ChangeSet<A, <I as Indexer>::ChangeSet>
Insert and index a transaction into the graph.
pub fn insert_anchor(
&mut self,
txid: Txid,
anchor: A,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn insert_anchor( &mut self, txid: Txid, anchor: A, ) -> ChangeSet<A, <I as Indexer>::ChangeSet>
Insert an anchor
for a given transaction.
pub fn insert_seen_at(
&mut self,
txid: Txid,
seen_at: u64,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn insert_seen_at( &mut self, txid: Txid, seen_at: u64, ) -> ChangeSet<A, <I as Indexer>::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.
pub fn batch_insert_relevant<T>(
&mut self,
txs: impl IntoIterator<Item = (T, impl IntoIterator<Item = A>)>,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn batch_insert_relevant<T>( &mut self, txs: impl IntoIterator<Item = (T, impl IntoIterator<Item = A>)>, ) -> ChangeSet<A, <I as Indexer>::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.
pub fn batch_insert_relevant_unconfirmed<T>(
&mut self,
unconfirmed_txs: impl IntoIterator<Item = (T, u64)>,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn batch_insert_relevant_unconfirmed<T>( &mut self, unconfirmed_txs: impl IntoIterator<Item = (T, u64)>, ) -> ChangeSet<A, <I as Indexer>::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).
pub fn batch_insert_unconfirmed<T>(
&mut self,
txs: impl IntoIterator<Item = (T, u64)>,
) -> ChangeSet<A, <I as Indexer>::ChangeSet>
pub fn batch_insert_unconfirmed<T>( &mut self, txs: impl IntoIterator<Item = (T, u64)>, ) -> ChangeSet<A, <I as Indexer>::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.