Skip to content

Commit

Permalink
[chain_redesign] Relax generic constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlinjin committed May 3, 2023
1 parent face9ff commit 79e4e68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions crates/chain/src/indexed_tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
/// A struct that combines [`TxGraph`] and an [`Indexer`] implementation.
///
/// This structure ensures that [`TxGraph`] and [`Indexer`] are updated atomically.
#[derive(Debug)]
pub struct IndexedTxGraph<A, I> {
/// Transaction index.
pub index: I,
Expand All @@ -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.
pub fn graph(&self) -> &TxGraph<A> {
&self.graph
}
}

impl<A: Anchor, I: Indexer> IndexedTxGraph<A, I> {
/// Applies the [`IndexedAdditions`] to the [`IndexedTxGraph`].
pub fn apply_additions(&mut self, additions: IndexedAdditions<A, I::Additions>) {
let IndexedAdditions {
Expand Down Expand Up @@ -217,7 +220,7 @@ impl<A: Anchor, I: OwnedIndexer> IndexedTxGraph<A, I> {
C: ChainOracle,
F: FnMut(&Script) -> bool,
{
let tip_height = chain_tip.anchor_block().height;
let tip_height = chain_tip.height;

let mut immature = 0;
let mut trusted_pending = 0;
Expand Down
6 changes: 3 additions & 3 deletions crates/chain/src/keychain/txout_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>;

fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {
Expand All @@ -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 {
self.inner().is_spk_owned(spk)
self.index_of_spk(spk).is_some()
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/chain/src/spk_txout_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ();

fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {
Expand Down

0 comments on commit 79e4e68

Please sign in to comment.