bdk icon indicating copy to clipboard operation
bdk copied to clipboard

refactor(chain)!: Remove `Anchor` trait and make anchors unique to (Txid, BlockId)

Open LagginTimes opened this issue 1 year ago • 5 comments

Resolves bitcoindevkit/bdk_wallet#90.

Description

The Anchor trait has been removed and anchors are now unique to (Txid, BlockId).

Notes to the reviewers

Documentation have been mostly untouched and need to be written/updated.

Changelog notice

  • Anchor trait has been removed.
  • Anchor type and BlockTime struct have been added to bdk_chain.

Checklists

All Submissions:

  • [x] I've signed all my commits
  • [x] I followed the contribution guidelines
  • [x] I ran cargo fmt and cargo clippy before committing

LagginTimes avatar Jul 17 '24 13:07 LagginTimes

@notmandatory I prefer we rebase this on top of bitcoindevkit/bdk#1514 since that PR is more "final" than this one.

evanlinjin avatar Jul 18 '24 10:07 evanlinjin

As discussed privately, it makes sense to rm TxGraph::anchors field.

pub struct TxGraph<AM = BlockTime> {
    // all transactions that the graph is aware of in format: `(tx_node, tx_anchors)`
    txs: HashMap<Txid, (TxNodeInternal, BTreeMap<BlockId, AM>)>,
    spends: BTreeMap<OutPoint, HashSet<Txid>>,
    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>,
}

See P.O.C: https://github.com/bitcoindevkit/bdk/commit/63d9e6a8973e0657ab6d9d9eadac8e544c15125c

evanlinjin avatar Jul 18 '24 13:07 evanlinjin

This is great work. However, we have concluded that we do not have enough time to get this into v1.0.beta (as discussed).

evanlinjin avatar Jul 19 '24 11:07 evanlinjin

I'll move this out of the alpha milestone, thanks guys.

notmandatory avatar Jul 19 '24 20:07 notmandatory

Technically wallet ChangeSet is part of the public wallet API I'll move this to 2.0.

notmandatory avatar Jul 20 '24 01:07 notmandatory