LLFourn / bdk_core_staging

Staging area for bdk_core initial development
15 stars 12 forks source link

Introduce `SparseChain` index extension #60

Closed evanlinjin closed 1 year ago

evanlinjin commented 1 year ago

This description is mostly copied from #61

Usually transactions are indexed by their height. But you might want to extend this (e.g. include block position) or some other metadata.

I've made the index quite restrictive (e.g. requires Copy) since we'll need to persist the data and for our simple file based persistence we'll need it to be fixed size for now.

This fixes a bug where an inclusive txid range search would not find the txids because we set the range to Txid::all_zeros (unless the txid was all zeroes).

I also added an API to search via the index itself. Handy if you want to do pagination of transactions by your own index (a good one would be block position) as mentioned in https://github.com/bitcoindevkit/bdk/issues/794

To Do

codecov-commenter commented 1 year ago

Codecov Report

Merging #60 (1e0f0ca) into master (17e0698) will increase coverage by 15.99%. The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           master      #60       +/-   ##
===========================================
+ Coverage   55.04%   71.04%   +15.99%     
===========================================
  Files           8        7        -1     
  Lines        1228      891      -337     
===========================================
- Hits          676      633       -43     
+ Misses        552      258      -294     
Impacted Files Coverage Δ
bdk_core/src/lib.rs 25.92% <ø> (ø)
bdk_core/src/sparse_chain.rs 37.83% <100.00%> (+20.82%) :arrow_up:
bdk_core/src/chain_graph.rs

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.