-
Notifications
You must be signed in to change notification settings - Fork 68
Remove Anchor trait and make anchors unique to (Txid, BlockId) #90
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
The Problem
Why remove Anchor trait?
We don't need it. Confirmation block and anchor block will be the same block after bitcoindevkit/bdk#1489 is merged.
Anchor representation in TxGraph and tx_graph::ChangeSet is bad
This is how anchors are represented now.
pub struct TxGraph<A = ()> {
anchors: BTreeSet<(A, Txid)>,
// ... OTHER FIELDS
}
pub struct ChangeSet<A = ()> {
pub anchors: BTreeSet<(A, Txid)>,
// ... OTHER FIELDS
}However, we can have multiple As that have the same anchor block BlockId for the same Txid. This is not ideal. Ideally, we want one anchor per (BlockId, Txid).
The Proposal
pub type Anchor = (Txid, BlockId);
pub struct TxGraph<AM> {
anchors: BTreeMap<Anchor, AM>,
}
pub struct ChangeSet<AM> {
anchors: BTreeMap<Anchor, AM>,
}Where AM is "anchor metadata". I.e. You can store block time here (u32).
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
No status
Status
In Progress