Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove indexed tx graph (2) #1875

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

evanlinjin
Copy link
Member

Description

This is a temporary duplicate of #1510 so see if @ValuedMammal is happy with these changes.

  • tx_graph::ChangeSet is the nested structure.
  • tx_graph::TxChangeSet is the changeset without the indexer data.

@evanlinjin evanlinjin force-pushed the remove-indexed-tx-graph branch 2 times, most recently from a202349 to 7d8ffae Compare March 7, 2025 03:50
in favour of adding a type parameter to TxGraph.
When the second type parameter `X: Indexer` is set then TxGraph behaves
like `IndexedTxGraph` used to.

I reworked the internals of `TxGraph` as I thought things were a bit
convoluted.

- feat: allow changing the indexer on TxGraph

Co-authored: LLFourn
The serialization format of the nested structure is exactly the same as
the as the old `indexed_tx_graph::ChangeSet`. The old
`tx_graph::ChangeSet` is replaced with `tx_graph::TxChangeSet`.
@evanlinjin evanlinjin force-pushed the remove-indexed-tx-graph branch from 7d8ffae to 1c026d6 Compare March 7, 2025 04:19
Copy link
Contributor

@ValuedMammal ValuedMammal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review ACK. tested locally with no issue. I had a question about when we should be calling index_changeset, and the rest are nits.

@@ -733,44 +888,108 @@ impl<A: Anchor> TxGraph<A> {
for (txid, seen_at) in update.seen_ats {
changeset.merge(self.insert_seen_at(txid, seen_at));
}
self.index_changeset(&mut changeset);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I'm not sure if this line is needed because both insert_tx and insert_txout will call index_changeset.

))
)]
#[must_use]
pub struct ChangeSet<A = (), XC = ()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could just call this I, but either way is fine.

Suggested change
pub struct ChangeSet<A = (), XC = ()> {
pub struct ChangeSet<A = (), I = ()> {

}

/// Changes the [`Indexer`] for a `TxGraph`. **This doesn't re-index the transactions in the
/// graph**. To do that that call [`reindex`].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// graph**. To do that that call [`reindex`].
/// graph**. To do that call [`reindex`].

@@ -1180,56 +1502,98 @@ impl<A: Ord> Merge for ChangeSet<A> {
}
}

impl<A: Ord> ChangeSet<A> {
/// The [`ChangeSet`] represents changes to a [`TxGraph`] and it's internal [`Indexer`].
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The [`ChangeSet`] represents changes to a [`TxGraph`] and it's internal [`Indexer`].
/// The [`ChangeSet`] represents changes to a [`TxGraph`] and its internal [`Indexer`].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants