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:
Arkadiy Paronyan
2018-07-03 17:44:43 +02:00
committed by Gav Wood
parent e6a7c64518
commit 12268ae700
52 changed files with 503 additions and 179 deletions
+1 -1
View File
@@ -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;
+11 -6
View File
@@ -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)
}
}