[bdk_chain_redesign] Rm anchor type param for structs that don't use it

This commit is contained in:
志宇
2023-03-28 14:58:59 +08:00
parent 3440a05711
commit 34d0277e44
16 changed files with 174 additions and 201 deletions

View File

@@ -10,9 +10,7 @@ use bdk_chain::{
tx_graph::{self, TxGraph, TxInGraph},
BlockId, TxHeight,
};
use bitcoin::{
BlockHash, OutPoint, PackedLockTime, Script, Sequence, Transaction, TxIn, TxOut, Witness,
};
use bitcoin::{OutPoint, PackedLockTime, Script, Sequence, Transaction, TxIn, TxOut, Witness};
#[test]
fn test_spent_by() {
@@ -47,7 +45,7 @@ fn test_spent_by() {
output: vec![],
};
let mut cg1 = ChainGraph::<(u32, BlockHash), _>::default();
let mut cg1 = ChainGraph::default();
let _ = cg1
.insert_tx(tx1, TxHeight::Unconfirmed)
.expect("should insert");
@@ -128,7 +126,7 @@ fn update_evicts_conflicting_tx() {
cg
};
let changeset = ChangeSet::<(u32, BlockHash), TxHeight> {
let changeset = ChangeSet::<TxHeight> {
chain: sparse_chain::ChangeSet {
checkpoints: Default::default(),
txids: [
@@ -137,7 +135,7 @@ fn update_evicts_conflicting_tx() {
]
.into(),
},
graph: tx_graph::Additions::<(u32, BlockHash)> {
graph: tx_graph::Additions {
tx: [tx_b2.clone()].into(),
txout: [].into(),
..Default::default()
@@ -154,7 +152,7 @@ fn update_evicts_conflicting_tx() {
{
let cg1 = {
let mut cg = ChainGraph::<(u32, BlockHash), _>::default();
let mut cg = ChainGraph::default();
let _ = cg.insert_checkpoint(cp_a).expect("should insert cp");
let _ = cg.insert_checkpoint(cp_b).expect("should insert cp");
let _ = cg
@@ -208,7 +206,7 @@ fn update_evicts_conflicting_tx() {
cg
};
let changeset = ChangeSet::<(u32, BlockHash), TxHeight> {
let changeset = ChangeSet::<TxHeight> {
chain: sparse_chain::ChangeSet {
checkpoints: [(1, Some(h!("B'")))].into(),
txids: [
@@ -217,7 +215,7 @@ fn update_evicts_conflicting_tx() {
]
.into(),
},
graph: tx_graph::Additions::<(u32, BlockHash)> {
graph: tx_graph::Additions {
tx: [tx_b2].into(),
txout: [].into(),
..Default::default()
@@ -256,7 +254,7 @@ fn chain_graph_new_missing() {
(tx_b.txid(), TxHeight::Confirmed(0))
]
);
let mut graph = TxGraph::<(u32, BlockHash)>::default();
let mut graph = TxGraph::default();
let mut expected_missing = HashSet::new();
expected_missing.insert(tx_a.txid());
@@ -293,7 +291,7 @@ fn chain_graph_new_missing() {
let new_graph = ChainGraph::new(update.clone(), graph.clone()).unwrap();
let expected_graph = {
let mut cg = ChainGraph::<(u32, BlockHash), TxHeight>::default();
let mut cg = ChainGraph::<TxHeight>::default();
let _ = cg
.insert_checkpoint(update.latest_checkpoint().unwrap())
.unwrap();
@@ -348,7 +346,7 @@ fn chain_graph_new_conflicts() {
]
);
let graph = TxGraph::<(u32, BlockHash)>::new([tx_a, tx_b, tx_b2]);
let graph = TxGraph::new([tx_a, tx_b, tx_b2]);
assert!(matches!(
ChainGraph::new(chain, graph),
@@ -358,7 +356,7 @@ fn chain_graph_new_conflicts() {
#[test]
fn test_get_tx_in_chain() {
let mut cg = ChainGraph::<(u32, BlockHash), _>::default();
let mut cg = ChainGraph::default();
let tx = Transaction {
version: 0x01,
lock_time: PackedLockTime(0),
@@ -383,7 +381,7 @@ fn test_get_tx_in_chain() {
#[test]
fn test_iterate_transactions() {
let mut cg = ChainGraph::<BlockId, _>::default();
let mut cg = ChainGraph::default();
let txs = (0..3)
.map(|i| Transaction {
version: i,
@@ -480,7 +478,7 @@ fn test_apply_changes_reintroduce_tx() {
// block1, block2a, tx1, tx2a
let mut cg = {
let mut cg = ChainGraph::<(u32, BlockHash), _>::default();
let mut cg = ChainGraph::default();
let _ = cg.insert_checkpoint(block1).unwrap();
let _ = cg.insert_checkpoint(block2a).unwrap();
let _ = cg.insert_tx(tx1, TxHeight::Confirmed(1)).unwrap();
@@ -636,7 +634,7 @@ fn test_evict_descendants() {
let txid_conflict = tx_conflict.txid();
let cg = {
let mut cg = ChainGraph::<(u32, BlockHash), TxHeight>::default();
let mut cg = ChainGraph::<TxHeight>::default();
let _ = cg.insert_checkpoint(block_1);
let _ = cg.insert_checkpoint(block_2a);
let _ = cg.insert_tx(tx_1, TxHeight::Confirmed(1));
@@ -648,7 +646,7 @@ fn test_evict_descendants() {
};
let update = {
let mut cg = ChainGraph::<(u32, BlockHash), TxHeight>::default();
let mut cg = ChainGraph::<TxHeight>::default();
let _ = cg.insert_checkpoint(block_1);
let _ = cg.insert_checkpoint(block_2b);
let _ = cg.insert_tx(tx_conflict.clone(), TxHeight::Confirmed(2));