Merge branch 'master' into governance

This commit is contained in:
Gav
2018-01-23 20:52:47 +01:00
22 changed files with 105 additions and 60 deletions
@@ -16,7 +16,11 @@
//! Environment API: Allows certain information to be accessed throughout the runtime.
use runtime_support::{Rc, RefCell, transmute, Box};
use runtime_support::boxed::Box;
use runtime_support::mem;
use runtime_support::cell::RefCell;
use runtime_support::rc::Rc;
use primitives::{BlockNumber, Digest};
#[derive(Default)]
@@ -48,7 +52,7 @@ fn env() -> Rc<RefCell<Environment>> {
let singleton: Rc<RefCell<Environment>> = Rc::new(RefCell::new(Default::default()));
// Put it in the heap so it can outlive this call
SINGLETON = transmute(Box::new(singleton));
SINGLETON = mem::transmute(Box::new(singleton));
}
// Now we give out a copy of the data that is safe to use concurrently.
@@ -69,7 +73,7 @@ fn env() -> Rc<RefCell<Environment>> {
let singleton: Rc<RefCell<Environment>> = Rc::new(RefCell::new(Default::default()));
// Put it in the heap so it can outlive this call
*s.borrow_mut() = transmute(Box::new(singleton));
*s.borrow_mut() = mem::transmute(Box::new(singleton));
}
// Now we give out a copy of the data that is safe to use concurrently.
@@ -16,12 +16,12 @@
//! Primitive types.
use runtime_support::Vec;
use runtime_support::prelude::*;
use streamreader::StreamReader;
use joiner::Joiner;
use slicable::{Slicable, NonTrivialSlicable};
use function::Function;
use runtime_support::{size_of, blake2_256, twox_128, twox_256, ed25519_verify};
use runtime_support::{mem, blake2_256, twox_128, twox_256, ed25519_verify};
#[cfg(test)]
use std::fmt;
@@ -86,7 +86,7 @@ impl Slicable for Header {
})
}
fn set_as_slice<F: Fn(&mut[u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
fn set_as_slice<F: Fn(&mut [u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
unimplemented!();
}
@@ -100,7 +100,7 @@ impl Slicable for Header {
}
fn size_of(data: &[u8]) -> Option<usize> {
let first_part = size_of::<Hash>() + size_of::<BlockNumber>() + size_of::<Hash>() + size_of::<Hash>();
let first_part = mem::size_of::<Hash>() + mem::size_of::<BlockNumber>() + mem::size_of::<Hash>() + mem::size_of::<Hash>();
let second_part = <Vec<Vec<u8>>>::size_of(&data[first_part..])?;
Some(first_part + second_part)
}
@@ -132,7 +132,7 @@ impl Slicable for Transaction {
})
}
fn set_as_slice<F: Fn(&mut[u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
fn set_as_slice<F: Fn(&mut [u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
unimplemented!();
}
@@ -145,7 +145,7 @@ impl Slicable for Transaction {
}
fn size_of(data: &[u8]) -> Option<usize> {
let first_part = size_of::<AccountID>() + size_of::<TxOrder>() + size_of::<u8>();
let first_part = mem::size_of::<AccountID>() + mem::size_of::<TxOrder>() + mem::size_of::<u8>();
let second_part = <Vec<u8>>::size_of(&data[first_part..])?;
Some(first_part + second_part)
}
@@ -210,7 +210,7 @@ impl Slicable for UncheckedTransaction {
})
}
fn set_as_slice<F: Fn(&mut[u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
fn set_as_slice<F: Fn(&mut [u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
unimplemented!();
}
@@ -221,7 +221,7 @@ impl Slicable for UncheckedTransaction {
}
fn size_of(data: &[u8]) -> Option<usize> {
let first_part = size_of::<[u8; 64]>();
let first_part = mem::size_of::<[u8; 64]>();
let second_part = <Transaction>::size_of(&data[first_part..])?;
Some(first_part + second_part)
}
@@ -247,7 +247,7 @@ impl Slicable for Block {
})
}
fn set_as_slice<F: Fn(&mut[u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
fn set_as_slice<F: Fn(&mut [u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
unimplemented!();
}
@@ -281,7 +281,7 @@ impl<T: NonTrivialSlicable> Slicable for Vec<T> {
Some(r)
}
fn set_as_slice<F: Fn(&mut[u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
fn set_as_slice<F: Fn(&mut [u8], usize) -> bool>(_fill_slice: &F) -> Option<Self> {
unimplemented!();
}
@@ -17,7 +17,8 @@
//! Proposal: This describes a combination of a function ID and data that can be used to call into
//! an internal function.
use runtime_support::{size_of, Vec};
use runtime_support::prelude::*;
use runtime_support::mem;
use slicable::Slicable;
use joiner::Joiner;
use streamreader::StreamReader;
@@ -74,7 +75,7 @@ impl Slicable for Proposal {
}
fn size_of(data: &[u8]) -> Option<usize> {
let first_part = size_of::<u8>();
let first_part = mem::size_of::<u8>();
let second_part = <Vec<u8>>::size_of(&data[first_part..])?;
Some(first_part + second_part)
}
@@ -18,7 +18,8 @@
use slicable::Slicable;
use keyedvec::KeyedVec;
use runtime_support::{self, twox_128, Vec};
use runtime_support::prelude::*;
use runtime_support::{self, twox_128};
/// Trait for a value which may be stored in the storage DB.
pub trait Storable {