Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request paritytech#161 from subspace/rename-CallObjectLoca…
Browse files Browse the repository at this point in the history
…tion

Rename `CallObjectLocation` to `CallObject`
  • Loading branch information
nazar-pc committed Dec 3, 2021
2 parents 8fb5483 + e4bacfc commit b912cba
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions crates/pallet-feeds/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Config> Call<T> {
/// Extract object location if an extrinsic corresponds to `put` call
pub fn extract_object_location(&self) -> Option<CallObjectLocation> {
/// Extract the call object if an extrinsic corresponds to `put` call
pub fn extract_call_object(&self) -> Option<CallObject> {
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::<FeedId>() as u32,
})
Expand Down
8 changes: 4 additions & 4 deletions crates/pallet-object-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Config> Call<T> {
/// Extract object location if an extrinsic corresponds to `put` call
pub fn extract_object_location(&self) -> Option<CallObjectLocation> {
pub fn extract_call_object(&self) -> Option<CallObject> {
match self {
Self::put { data } => {
// `1` corresponds to `Call::put {}` enum variant encoding.
Some(CallObjectLocation {
Some(CallObject {
hash: crypto::sha256_hash(data),
offset: 1,
})
Expand Down
4 changes: 2 additions & 2 deletions crates/subspace-core-primitives/src/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,10 +414,10 @@ fn extract_feeds_block_object_mapping(
objects: &mut Vec<BlockObject>,
call: &pallet_feeds::Call<Runtime>,
) {
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,
});
}
}
Expand All @@ -427,10 +427,10 @@ fn extract_object_store_block_object_mapping(
objects: &mut Vec<BlockObject>,
call: &pallet_object_store::Call<Runtime>,
) {
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,
});
}
}
Expand Down

0 comments on commit b912cba

Please sign in to comment.