Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Hide OpaqueExtrinsic internal and add builder
  • Loading branch information
cecton committed Jun 26, 2020
commit 6ec71cbf0df95b3e1d113392e4c1e6d60b31e871
2 changes: 1 addition & 1 deletion primitives/runtime/src/generic/unchecked_extrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ where
Extra: SignedExtension,
{
fn from(extrinsic: UncheckedExtrinsic<Address, Call, Signature, Extra>) -> Self {
OpaqueExtrinsic::decode(&mut extrinsic.encode().as_slice())
OpaqueExtrinsic::from_bytes(extrinsic.encode().as_slice())
.expect(
"both OpaqueExtrinsic and UncheckedExtrinsic have encoding that is compatible with \
raw Vec<u8> encoding; qed"
Expand Down
9 changes: 8 additions & 1 deletion primitives/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,14 @@ macro_rules! assert_eq_error_rate {
/// Simple blob to hold an extrinsic without committing to its format and ensure it is serialized
/// correctly.
#[derive(PartialEq, Eq, Clone, Default, Encode, Decode)]
pub struct OpaqueExtrinsic(pub Vec<u8>);
pub struct OpaqueExtrinsic(Vec<u8>);

impl OpaqueExtrinsic {
/// Convert an encoded extrinsic to an `OpaqueExtrinsic`.
pub fn from_bytes(mut bytes: &[u8]) -> Result<Self, codec::Error> {
OpaqueExtrinsic::decode(&mut bytes)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this is an &mut but it seems I didn't need an &mut to call it. (And bytes is a reference so it can't be modified)

}
}

#[cfg(feature = "std")]
impl parity_util_mem::MallocSizeOf for OpaqueExtrinsic {
Expand Down