-
Notifications
You must be signed in to change notification settings - Fork 311
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
Fixes #1665: #1670
base: master
Are you sure you want to change the base?
Fixes #1665: #1670
Conversation
spends: BTreeMap<OutPoint, HashSet<Txid>>, | ||
anchors: BTreeSet<(A, Txid)>, | ||
anchors: HashMap<Txid, BTreeSet<A>>, | ||
last_seen: HashMap<Txid, u64>, | ||
|
||
// This atrocity exists so that `TxGraph::outspends()` can return a reference. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to call this an "atrocity" since it's the best way to do it.
// This atrocity exists so that `TxGraph::outspends()` can return a reference. | |
// This exists so that `TxGraph::outspends()` can return a reference to an empty set of `Txid`s. |
last_seen: HashMap<Txid, u64>, | ||
|
||
// This atrocity exists so that `TxGraph::outspends()` can return a reference. | ||
// FIXME: This can be removed once `HashSet::new` is a const fn. | ||
empty_outspends: HashSet<Txid>, | ||
empty_anchors: BTreeSet<A>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
empty_anchors: BTreeSet<A>, | |
// This exists so that `TxGraph` functions can return a reference to an empty set of `TxNode.anchors`. | |
empty_anchors: BTreeSet<A>, |
/// ChainPosition::Unconfirmed(last_seen) => println!( | ||
/// "tx is last seen at {}, it is unconfirmed as it is not anchored in the best chain", | ||
/// last_seen, | ||
/// ), | ||
/// ChainPosition::UnconfirmedAndNotSeen => println!( | ||
/// "tx does not conflict with anything canonical, but we never seen it in mempool", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛏️ grammar nit
/// "tx does not conflict with anything canonical, but we never seen it in mempool", | |
/// "tx does not conflict with anything canonical, but we have never seen it in the mempool", |
Previously, the field `TxGraph::anchors` existed because we assumed there was use in having a partially-chronological order of transactions there. Turns out it wasn't used at all. This commit removes anchors from the `txs` field and reworks `anchors` field to be a map of `txid -> set<anchors>`. This is a breaking change since the signature of `all_anchors()` is changed.
Per call today @evanlinjin will open a new PR for the 1.0.0-beta milestone that only makes expected breaking changes for |
6abc6d0
to
c34e915
Compare
This is an O(n) algorithm to determine the canonical set of txids.
8c34407
to
5278b81
Compare
On further discussion today at release planning call this PR was moved back into the 1.0 milestone if it can be completed and reviewed in time. If not it will have to wait for a 2.0 milestone because it required breaking changes to chain crate APIs that are exposed in the Alternatively we could remove the following /// Get a reference to the inner [`TxGraph`].
pub fn tx_graph(&self) -> &TxGraph<ConfirmationBlockTime> {
self.indexed_graph.graph()
}
/// Get a reference to the inner [`KeychainTxOutIndex`].
pub fn spk_index(&self) -> &KeychainTxOutIndex<KeychainKind> {
&self.indexed_graph.index
}
/// Get a reference to the inner [`LocalChain`].
pub fn local_chain(&self) -> &LocalChain {
&self.chain
} |
@notmandatory how does this solution compare with just giving wallet a major version bump? |
Removing the above functions and moving required chain error type to core should allow us to do breaking chain crate api changes without having to do a major wallet crate release. I also don't see why Wallet users need to access the inner chain types directly instead of using higher level functions like But all that said if it's less risky to just keep everything as is and do a 2.0 release in 6 mo or so I'd be fine with that too. |
Fixes #1665
Replaces #1659
Description
Implement an
O(n)
algorithm to determine the canonical set of transactions ofTxGraph
.Notes to the reviewers
This is an initial, untested PR. Just here to show progress. Feedback welcome.
Changelog notice
TODO
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
Bugfixes: