[bdk_chain_redesign] Introduce BlockAnchor trait

* Introduce `GraphedTx` struct to access transaction data of graphed
  transactions.
* Ability to insert/access anchors and "seen at" values for graphed
  transactions.
* `Additions` now records changes to anchors and last_seen_at.
This commit is contained in:
志宇
2023-03-24 09:23:36 +08:00
parent 82f9caddab
commit 5ae5fe30eb
21 changed files with 584 additions and 298 deletions

View File

@@ -32,7 +32,7 @@ use bdk_chain::{
keychain::KeychainScan,
sparse_chain::{self, ChainPosition, SparseChain},
tx_graph::TxGraph,
BlockId, ConfirmationTime, TxHeight,
BlockAnchor, BlockId, ConfirmationTime, TxHeight,
};
pub use electrum_client;
use electrum_client::{Client, ElectrumApi, Error};
@@ -243,13 +243,14 @@ impl<K: Ord + Clone + Debug, P: ChainPosition> ElectrumUpdate<K, P> {
/// `tracker`.
///
/// This will fail if there are missing full transactions not provided via `new_txs`.
pub fn into_keychain_scan<CG>(
pub fn into_keychain_scan<CG, A>(
self,
new_txs: Vec<Transaction>,
chain_graph: &CG,
) -> Result<KeychainScan<K, P>, chain_graph::NewError<P>>
) -> Result<KeychainScan<K, A, P>, chain_graph::NewError<P>>
where
CG: AsRef<ChainGraph<P>>,
CG: AsRef<ChainGraph<A, P>>,
A: BlockAnchor,
{
Ok(KeychainScan {
update: chain_graph