Sandboxing and the simplest smart-contract runtime (#140)

* Add primitives for sandboxing.

* Add sandbox module.

* Implement the runtime part of the sandbox.

* Rebuild binaries.

* Implement smart-contract execution.

* Add more documentation.
This commit is contained in:
Sergey Pepyakin
2018-05-01 21:32:01 +03:00
committed by Robert Habermeier
parent f116f67382
commit 5a56fbcea3
39 changed files with 2470 additions and 56 deletions
+25
View File
@@ -61,6 +61,31 @@ pub trait Slicable: Sized {
}
}
impl<T: Slicable, E: Slicable> Slicable for Result<T, E> {
fn decode<I: Input>(input: &mut I) -> Option<Self> {
match input.read_byte()? {
0 => Some(Ok(T::decode(input)?)),
1 => Some(Err(E::decode(input)?)),
_ => None,
}
}
fn encode(&self) -> Vec<u8> {
let mut v = Vec::new();
match *self {
Ok(ref t) => {
v.push(0);
t.using_encoded(|s| v.extend(s));
}
Err(ref e) => {
v.push(1);
e.using_encoded(|s| v.extend(s));
}
}
v
}
}
impl Slicable for Option<bool> {
fn decode<I: Input>(input: &mut I) -> Option<Self> {
match input.read_byte()? {