From e4bacfc097dcad40c040f924462e104a9924cfd1 Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Thu, 2 Dec 2021 17:10:59 +0800 Subject: [PATCH] Rename `CallObjectLocation` to `CallObject` --- crates/pallet-feeds/src/lib.rs | 10 +++++----- crates/pallet-object-store/src/lib.rs | 8 ++++---- crates/subspace-core-primitives/src/objects.rs | 4 ++-- crates/subspace-runtime/src/lib.rs | 12 ++++++------ 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/crates/pallet-feeds/src/lib.rs b/crates/pallet-feeds/src/lib.rs index e70399ee93165..81f40e5011cda 100644 --- a/crates/pallet-feeds/src/lib.rs +++ b/crates/pallet-feeds/src/lib.rs @@ -150,21 +150,21 @@ mod pallet { /// Mapping to the object offset and size within an extrinsic #[derive(Debug)] -pub struct CallObjectLocation { +pub struct CallObject { /// Object hash pub hash: Sha256Hash, - /// Offset + /// Offset of object in the encoded call. pub offset: u32, } impl Call { - /// Extract object location if an extrinsic corresponds to `put` call - pub fn extract_object_location(&self) -> Option { + /// Extract the call object if an extrinsic corresponds to `put` call + pub fn extract_call_object(&self) -> Option { match self { Self::put { data, .. } => { // `FeedId` is the first field in the extrinsic. `1+` corresponds to `Call::put {}` // enum variant encoding. - Some(CallObjectLocation { + Some(CallObject { hash: crypto::sha256_hash(data), offset: 1 + mem::size_of::() as u32, }) diff --git a/crates/pallet-object-store/src/lib.rs b/crates/pallet-object-store/src/lib.rs index cb85c235a2abe..056eaaf4cb0c7 100644 --- a/crates/pallet-object-store/src/lib.rs +++ b/crates/pallet-object-store/src/lib.rs @@ -83,20 +83,20 @@ mod pallet { /// Mapping to the object offset and size within an extrinsic #[derive(Debug)] -pub struct CallObjectLocation { +pub struct CallObject { /// Object hash pub hash: Sha256Hash, - /// Offset + /// Offset of object in the encoded call. pub offset: u32, } impl Call { /// Extract object location if an extrinsic corresponds to `put` call - pub fn extract_object_location(&self) -> Option { + pub fn extract_call_object(&self) -> Option { match self { Self::put { data } => { // `1` corresponds to `Call::put {}` enum variant encoding. - Some(CallObjectLocation { + Some(CallObject { hash: crypto::sha256_hash(data), offset: 1, }) diff --git a/crates/subspace-core-primitives/src/objects.rs b/crates/subspace-core-primitives/src/objects.rs index 24c734090dee5..f62fd805a7f6a 100644 --- a/crates/subspace-core-primitives/src/objects.rs +++ b/crates/subspace-core-primitives/src/objects.rs @@ -41,7 +41,7 @@ pub enum BlockObject { V0 { /// Object hash hash: Sha256Hash, - /// Offset of the object. + /// Offset of object in the encoded block. offset: u32, }, } @@ -54,7 +54,7 @@ impl BlockObject { } } - /// Offset of the object. + /// Offset of object in the encoded block. pub fn offset(&self) -> u32 { match self { Self::V0 { offset, .. } => *offset, diff --git a/crates/subspace-runtime/src/lib.rs b/crates/subspace-runtime/src/lib.rs index 4558e56dd6189..23183dc97f05e 100644 --- a/crates/subspace-runtime/src/lib.rs +++ b/crates/subspace-runtime/src/lib.rs @@ -414,10 +414,10 @@ fn extract_feeds_block_object_mapping( objects: &mut Vec, call: &pallet_feeds::Call, ) { - if let Some(call_object_location) = call.extract_object_location() { + if let Some(call_object) = call.extract_call_object() { objects.push(BlockObject::V0 { - hash: call_object_location.hash, - offset: base_offset + call_object_location.offset, + hash: call_object.hash, + offset: base_offset + call_object.offset, }); } } @@ -427,10 +427,10 @@ fn extract_object_store_block_object_mapping( objects: &mut Vec, call: &pallet_object_store::Call, ) { - if let Some(call_object_location) = call.extract_object_location() { + if let Some(call_object) = call.extract_call_object() { objects.push(BlockObject::V0 { - hash: call_object_location.hash, - offset: base_offset + call_object_location.offset, + hash: call_object.hash, + offset: base_offset + call_object.offset, }); } }