chore(chain)!: Rename Append to Merge

This commit is contained in:
Wei Chen
2024-07-04 22:09:04 +08:00
parent db8fbd729d
commit 962305f415
16 changed files with 117 additions and 117 deletions

View File

@@ -10,7 +10,7 @@ use bdk_chain::{
indexed_tx_graph::{self, IndexedTxGraph},
indexer::keychain_txout::KeychainTxOutIndex,
local_chain::LocalChain,
tx_graph, Append, Balance, ChainPosition, ConfirmationHeightAnchor, DescriptorExt,
tx_graph, Balance, ChainPosition, ConfirmationHeightAnchor, DescriptorExt, Merge,
};
use bitcoin::{
secp256k1::Secp256k1, Amount, OutPoint, Script, ScriptBuf, Transaction, TxIn, TxOut,

View File

@@ -5,7 +5,7 @@ mod common;
use bdk_chain::{
collections::BTreeMap,
indexer::keychain_txout::{ChangeSet, KeychainTxOutIndex},
Append, DescriptorExt, DescriptorId, Indexer,
DescriptorExt, DescriptorId, Indexer, Merge,
};
use bitcoin::{secp256k1::Secp256k1, Amount, OutPoint, ScriptBuf, Transaction, TxOut};
@@ -51,13 +51,13 @@ fn spk_at_index(descriptor: &Descriptor<DescriptorPublicKey>, index: u32) -> Scr
}
// We create two empty changesets lhs and rhs, we then insert various descriptors with various
// last_revealed, append rhs to lhs, and check that the result is consistent with these rules:
// last_revealed, merge rhs to lhs, and check that the result is consistent with these rules:
// - Existing index doesn't update if the new index in `other` is lower than `self`.
// - Existing index updates if the new index in `other` is higher than `self`.
// - Existing index is unchanged if keychain doesn't exist in `other`.
// - New keychain gets added if the keychain is in `other` but not in `self`.
#[test]
fn append_changesets_check_last_revealed() {
fn merge_changesets_check_last_revealed() {
let secp = bitcoin::secp256k1::Secp256k1::signing_only();
let descriptor_ids: Vec<_> = DESCRIPTORS
.iter()
@@ -88,7 +88,7 @@ fn append_changesets_check_last_revealed() {
keychains_added: BTreeMap::<(), _>::new(),
last_revealed: rhs_di,
};
lhs.append(rhs);
lhs.merge(rhs);
// Existing index doesn't update if the new index in `other` is lower than `self`.
assert_eq!(lhs.last_revealed.get(&descriptor_ids[0]), Some(&7));
@@ -677,7 +677,7 @@ fn applying_changesets_one_by_one_vs_aggregate_must_have_same_result() {
.iter()
.cloned()
.reduce(|mut agg, cs| {
agg.append(cs);
agg.merge(cs);
agg
})
.expect("must aggregate changesets");

View File

@@ -7,7 +7,7 @@ use bdk_chain::{
collections::*,
local_chain::LocalChain,
tx_graph::{ChangeSet, TxGraph},
Anchor, Append, BlockId, ChainOracle, ChainPosition, ConfirmationHeightAnchor,
Anchor, BlockId, ChainOracle, ChainPosition, ConfirmationHeightAnchor, Merge,
};
use bitcoin::{
absolute, hashes::Hash, transaction, Amount, BlockHash, OutPoint, ScriptBuf, SignedAmount,
@@ -1049,9 +1049,9 @@ fn test_chain_spends() {
.is_none());
}
/// Ensure that `last_seen` values only increase during [`Append::append`].
/// Ensure that `last_seen` values only increase during [`Merge::merge`].
#[test]
fn test_changeset_last_seen_append() {
fn test_changeset_last_seen_merge() {
let txid: Txid = h!("test txid");
let test_cases: &[(Option<u64>, Option<u64>)] = &[
@@ -1074,7 +1074,7 @@ fn test_changeset_last_seen_append() {
};
assert!(!update.is_empty() || update_ls.is_none());
original.append(update);
original.merge(update);
assert_eq!(
&original.last_seen.get(&txid).cloned(),
Ord::max(original_ls, update_ls),