mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-28 11:01:14 +00:00
Runtime version (#256)
* Runtime version * Updated genesis.wasm * Minor fixes * Fresh runtime * Default version for pre Poc-2; Fixed authorship interface check * Fixed authoring check
This commit is contained in:
committed by
Gav Wood
parent
e6a7c64518
commit
12268ae700
@@ -38,6 +38,6 @@ mod slicable;
|
||||
mod joiner;
|
||||
mod keyedvec;
|
||||
|
||||
pub use self::slicable::{Input, Slicable};
|
||||
pub use self::slicable::{Input, Slicable, encode_slice};
|
||||
pub use self::joiner::Joiner;
|
||||
pub use self::keyedvec::KeyedVec;
|
||||
|
||||
@@ -63,6 +63,16 @@ pub trait Slicable: Sized {
|
||||
}
|
||||
}
|
||||
|
||||
/// Encode a bytes slice as `Slicable` that can be decoded into a vector.
|
||||
pub fn encode_slice(bytes: &[u8]) -> Vec<u8> {
|
||||
let len = bytes.len();
|
||||
assert!(len <= u32::max_value() as usize, "Attempted to serialize a collection with too many elements.");
|
||||
|
||||
let mut r: Vec<u8> = Vec::new().and(&(len as u32));
|
||||
r.extend_from_slice(bytes);
|
||||
r
|
||||
}
|
||||
|
||||
impl<T: Slicable, E: Slicable> Slicable for Result<T, E> {
|
||||
fn decode<I: Input>(input: &mut I) -> Option<Self> {
|
||||
match input.read_byte()? {
|
||||
@@ -182,12 +192,7 @@ impl Slicable for Vec<u8> {
|
||||
}
|
||||
|
||||
fn encode(&self) -> Vec<u8> {
|
||||
let len = self.len();
|
||||
assert!(len <= u32::max_value() as usize, "Attempted to serialize vec with too many elements.");
|
||||
|
||||
let mut r: Vec<u8> = Vec::new().and(&(len as u32));
|
||||
r.extend_from_slice(self);
|
||||
r
|
||||
encode_slice(&self)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user