diff --git a/core/src/config/mod.rs b/core/src/config/mod.rs index de6e296c0b..af3d74af23 100644 --- a/core/src/config/mod.rs +++ b/core/src/config/mod.rs @@ -47,7 +47,7 @@ pub trait Config: Sized + Send + Sync + 'static { type Hasher: Debug + Clone + Copy + Hasher + Send + Sync; /// The block header. - type Header: Debug + Header + Sync + Send + DeserializeOwned; + type Header: Debug + Header + Sync + Send + DeserializeOwned + Clone; /// This type defines the extrinsic extra and additional parameters. type ExtrinsicParams: ExtrinsicParams; diff --git a/subxt/src/blocks/block_types.rs b/subxt/src/blocks/block_types.rs index 1672c679cc..00326d7f4d 100644 --- a/subxt/src/blocks/block_types.rs +++ b/subxt/src/blocks/block_types.rs @@ -27,6 +27,17 @@ pub struct Block { cached_events: CachedEvents, } +impl Clone for Block { + fn clone(&self) -> Self { + Self { + header: self.header.clone(), + block_ref: self.block_ref.clone(), + client: self.client.clone(), + cached_events: self.cached_events.clone(), + } + } +} + // A cache for our events so we don't fetch them more than once when // iterating over events for extrinsics. pub(crate) type CachedEvents = Arc>>>; diff --git a/testing/integration-tests/src/full_client/blocks.rs b/testing/integration-tests/src/full_client/blocks.rs index c5a84c2a5d..99125429c8 100644 --- a/testing/integration-tests/src/full_client/blocks.rs +++ b/testing/integration-tests/src/full_client/blocks.rs @@ -205,6 +205,10 @@ async fn fetch_block_and_decode_extrinsic_details() { // Now, separately, download that block. Let's see what it contains.. let block_hash = in_block.block_hash(); let block = api.blocks().at(block_hash).await.unwrap(); + + // Ensure that we can clone the block. + block.clone(); + let extrinsics = block.extrinsics().await.unwrap(); assert_eq!(extrinsics.block_hash(), block_hash);