From: 志宇 Date: Fri, 6 Feb 2026 09:37:26 +0000 (+0000) Subject: feat(chain)!: Relax the generic parameter for `LocalChain` X-Git-Url: http://internal-gitweb-vhost/?a=commitdiff_plain;h=bf6541b43d3d65f20a7c081129197337f09d25b6;p=bdk feat(chain)!: Relax the generic parameter for `LocalChain` Use `D: Clone` instead of `D: Copy`. --- diff --git a/crates/chain/src/local_chain.rs b/crates/chain/src/local_chain.rs index d1d0535b..fd99e2ed 100644 --- a/crates/chain/src/local_chain.rs +++ b/crates/chain/src/local_chain.rs @@ -17,7 +17,7 @@ fn apply_changeset_to_checkpoint( changeset: &ChangeSet, ) -> Result, MissingGenesisError> where - D: ToBlockHash + fmt::Debug + Copy, + D: ToBlockHash + fmt::Debug + Clone, { if let Some(start_height) = changeset.blocks.keys().next().cloned() { // changes after point of agreement @@ -34,10 +34,10 @@ where } } - for (&height, &data) in &changeset.blocks { + for (&height, data) in &changeset.blocks { match data { Some(data) => { - extension.insert(height, data); + extension.insert(height, data.clone()); } None => { extension.remove(&height); @@ -234,7 +234,7 @@ impl LocalChain { // Methods where `D: ToBlockHash` impl LocalChain where - D: ToBlockHash + fmt::Debug + Copy, + D: ToBlockHash + fmt::Debug + Clone, { /// Constructs a [`LocalChain`] from genesis data. pub fn from_genesis(data: D) -> (Self, ChangeSet) { @@ -263,7 +263,7 @@ where /// Construct a [`LocalChain`] from an initial `changeset`. pub fn from_changeset(changeset: ChangeSet) -> Result { - let genesis_entry = changeset.blocks.get(&0).copied().flatten(); + let genesis_entry = changeset.blocks.get(&0).cloned().flatten(); let genesis_data = match genesis_entry { Some(data) => data, None => return Err(MissingGenesisError), @@ -412,7 +412,7 @@ where match cur.get(exp_height) { Some(cp) => { if cp.height() != exp_height - || Some(cp.hash()) != exp_data.map(|d| d.to_blockhash()) + || Some(cp.hash()) != exp_data.as_ref().map(|d| d.to_blockhash()) { return false; } @@ -590,7 +590,7 @@ fn merge_chains( update_tip: CheckPoint, ) -> Result<(CheckPoint, ChangeSet), CannotConnectError> where - D: ToBlockHash + fmt::Debug + Copy, + D: ToBlockHash + fmt::Debug + Clone, { let mut changeset = ChangeSet::::default();