bitcoindevkit / bitcoindevkit/bdk_wallet
Remove `Anchor` trait and make anchors unique to `(Txid, BlockId)`
- Dominant language
- Rust
- Stars
- 59
- Forks
- 105
- Avg merge
- 10d 9h
- Merged PRs (30d)
- 1
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.
```rust
pub struct TxGraph {
anchors: BTreeSet<(A, Txid)>,
// ... OTHER FIELDS
}
pub struct ChangeSet {
pub anchors: BTreeSet<(A, Txid)>,
// ... OTHER FIELDS
}
```
However, we can have multiple `A`s 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
```rust
pub type Anchor = (Txid, BlockId);
pub struct TxGraph {
anchors: BTreeMap,
}
pub struct ChangeSet {
anchors: BTreeMap,
}
```
Where `AM` is "anchor metadata". I.e. You can store block time here (`u32`).
Contributor guide
Assessment
This issue has not been assessed yet.