mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-09 20:11:09 +00:00
chain_getBlock extrinsics encoding (#1024)
* deserialize without decoding * change decoding approach * fix tests * decode without allocating * strip compact prefix * cargo fmt * nit adjustment
This commit is contained in:
@@ -11,7 +11,7 @@ mod multi_signature;
|
||||
mod static_type;
|
||||
mod wrapper_opaque;
|
||||
|
||||
use codec::{Decode, Encode};
|
||||
use codec::{Compact, Decode, Encode};
|
||||
use derivative::Derivative;
|
||||
|
||||
pub use account_id::AccountId32;
|
||||
@@ -35,6 +35,14 @@ impl codec::Encode for Encoded {
|
||||
}
|
||||
}
|
||||
|
||||
/// Decodes a compact encoded value from the beginning of the provided bytes,
|
||||
/// returning the value and any remaining bytes.
|
||||
pub(crate) fn strip_compact_prefix(bytes: &[u8]) -> Result<(u64, &[u8]), codec::Error> {
|
||||
let cursor = &mut &*bytes;
|
||||
let val = <Compact<u64>>::decode(cursor)?;
|
||||
Ok((val.0, *cursor))
|
||||
}
|
||||
|
||||
/// A version of [`std::marker::PhantomData`] that is also Send and Sync (which is fine
|
||||
/// because regardless of the generic param, it is always possible to Send + Sync this
|
||||
/// 0 size type).
|
||||
|
||||
Reference in New Issue
Block a user