[chain_redesign] Relax generic constraints
This commit is contained in:
parent
085bf9413d
commit
4ae727a1fb
@ -12,6 +12,7 @@ use crate::{
|
|||||||
/// A struct that combines [`TxGraph`] and an [`Indexer`] implementation.
|
/// A struct that combines [`TxGraph`] and an [`Indexer`] implementation.
|
||||||
///
|
///
|
||||||
/// This structure ensures that [`TxGraph`] and [`Indexer`] are updated atomically.
|
/// This structure ensures that [`TxGraph`] and [`Indexer`] are updated atomically.
|
||||||
|
#[derive(Debug)]
|
||||||
pub struct IndexedTxGraph<A, I> {
|
pub struct IndexedTxGraph<A, I> {
|
||||||
/// Transaction index.
|
/// Transaction index.
|
||||||
pub index: I,
|
pub index: I,
|
||||||
@ -27,12 +28,14 @@ impl<A, I: Default> Default for IndexedTxGraph<A, I> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I> {
|
impl<A, I> IndexedTxGraph<A, I> {
|
||||||
/// Get a reference of the internal transaction graph.
|
/// Get a reference of the internal transaction graph.
|
||||||
pub fn graph(&self) -> &TxGraph<A> {
|
pub fn graph(&self) -> &TxGraph<A> {
|
||||||
&self.graph
|
&self.graph
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I> {
|
||||||
/// Applies the [`IndexedAdditions`] to the [`IndexedTxGraph`].
|
/// Applies the [`IndexedAdditions`] to the [`IndexedTxGraph`].
|
||||||
pub fn apply_additions(&mut self, additions: IndexedAdditions<A, I::Additions>) {
|
pub fn apply_additions(&mut self, additions: IndexedAdditions<A, I::Additions>) {
|
||||||
let IndexedAdditions {
|
let IndexedAdditions {
|
||||||
@ -217,7 +220,7 @@ impl<A: Anchor, I: OwnedIndexer> IndexedTxGraph<A, I> {
|
|||||||
C: ChainOracle,
|
C: ChainOracle,
|
||||||
F: FnMut(&Script) -> bool,
|
F: FnMut(&Script) -> bool,
|
||||||
{
|
{
|
||||||
let tip_height = chain_tip.anchor_block().height;
|
let tip_height = chain_tip.height;
|
||||||
|
|
||||||
let mut immature = 0;
|
let mut immature = 0;
|
||||||
let mut trusted_pending = 0;
|
let mut trusted_pending = 0;
|
||||||
|
@ -89,7 +89,7 @@ impl<K> Deref for KeychainTxOutIndex<K> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K: Clone + Ord + Debug + 'static> Indexer for KeychainTxOutIndex<K> {
|
impl<K: Clone + Ord + Debug> Indexer for KeychainTxOutIndex<K> {
|
||||||
type Additions = DerivationAdditions<K>;
|
type Additions = DerivationAdditions<K>;
|
||||||
|
|
||||||
fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {
|
fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {
|
||||||
@ -109,9 +109,9 @@ impl<K: Clone + Ord + Debug + 'static> Indexer for KeychainTxOutIndex<K> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K: Clone + Ord + Debug + 'static> OwnedIndexer for KeychainTxOutIndex<K> {
|
impl<K: Clone + Ord + Debug> OwnedIndexer for KeychainTxOutIndex<K> {
|
||||||
fn is_spk_owned(&self, spk: &Script) -> bool {
|
fn is_spk_owned(&self, spk: &Script) -> bool {
|
||||||
self.inner().is_spk_owned(spk)
|
self.index_of_spk(spk).is_some()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ impl<I> Default for SpkTxOutIndex<I> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: Clone + Ord + 'static> Indexer for SpkTxOutIndex<I> {
|
impl<I: Clone + Ord> Indexer for SpkTxOutIndex<I> {
|
||||||
type Additions = ();
|
type Additions = ();
|
||||||
|
|
||||||
fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {
|
fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user