Skip to content

Commit 5a568dc

Browse files
committed
feat(chain)!: Relax the generic parameter for LocalChain<D>
Use `D: Clone` instead of `D: Copy`.
1 parent 014c527 commit 5a568dc

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

crates/chain/src/local_chain.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn apply_changeset_to_checkpoint<D>(
1717
changeset: &ChangeSet<D>,
1818
) -> Result<CheckPoint<D>, MissingGenesisError>
1919
where
20-
D: ToBlockHash + fmt::Debug + Copy,
20+
D: ToBlockHash + fmt::Debug + Clone,
2121
{
2222
if let Some(start_height) = changeset.blocks.keys().next().cloned() {
2323
// changes after point of agreement
@@ -34,10 +34,10 @@ where
3434
}
3535
}
3636

37-
for (&height, &data) in &changeset.blocks {
37+
for (&height, data) in &changeset.blocks {
3838
match data {
3939
Some(data) => {
40-
extension.insert(height, data);
40+
extension.insert(height, data.clone());
4141
}
4242
None => {
4343
extension.remove(&height);
@@ -234,7 +234,7 @@ impl<D> LocalChain<D> {
234234
// Methods where `D: ToBlockHash`
235235
impl<D> LocalChain<D>
236236
where
237-
D: ToBlockHash + fmt::Debug + Copy,
237+
D: ToBlockHash + fmt::Debug + Clone,
238238
{
239239
/// Constructs a [`LocalChain`] from genesis data.
240240
pub fn from_genesis(data: D) -> (Self, ChangeSet<D>) {
@@ -263,7 +263,7 @@ where
263263

264264
/// Construct a [`LocalChain`] from an initial `changeset`.
265265
pub fn from_changeset(changeset: ChangeSet<D>) -> Result<Self, MissingGenesisError> {
266-
let genesis_entry = changeset.blocks.get(&0).copied().flatten();
266+
let genesis_entry = changeset.blocks.get(&0).cloned().flatten();
267267
let genesis_data = match genesis_entry {
268268
Some(data) => data,
269269
None => return Err(MissingGenesisError),
@@ -412,7 +412,7 @@ where
412412
match cur.get(exp_height) {
413413
Some(cp) => {
414414
if cp.height() != exp_height
415-
|| Some(cp.hash()) != exp_data.map(|d| d.to_blockhash())
415+
|| Some(cp.hash()) != exp_data.as_ref().map(|d| d.to_blockhash())
416416
{
417417
return false;
418418
}
@@ -594,7 +594,7 @@ fn merge_chains<D>(
594594
update_tip: CheckPoint<D>,
595595
) -> Result<(CheckPoint<D>, ChangeSet<D>), CannotConnectError>
596596
where
597-
D: ToBlockHash + fmt::Debug + Copy,
597+
D: ToBlockHash + fmt::Debug + Clone,
598598
{
599599
let mut changeset = ChangeSet::<D>::default();
600600

0 commit comments

Comments
 (0)