initial merge

This commit is contained in:
Robert Habermeier
2018-02-06 14:12:54 +01:00
21 changed files with 839 additions and 191 deletions
+24 -4
View File
@@ -38,7 +38,7 @@ pub mod runtime;
use runtime_std::prelude::*;
use codec::Slicable;
use primitives::transaction::UncheckedTransaction;
use primitives::block::Block;
use primitives::block::{Header, Block};
/// Execute a block, with `input` being the canonical serialisation of the block. Returns the
/// empty vector.
@@ -49,9 +49,29 @@ pub fn execute_block(mut input: &[u8]) -> Vec<u8> {
/// Execute a given, serialised, transaction. Returns the empty vector.
pub fn execute_transaction(mut input: &[u8]) -> Vec<u8> {
let header = Header::from_slice(&mut input).unwrap();
let utx = UncheckedTransaction::from_slice(&mut input).unwrap();
runtime::system::internal::execute_transaction(utx);
Vec::new()
let header = runtime::system::internal::execute_transaction(utx, header);
header.to_vec()
}
impl_stubs!(execute_block, execute_transaction);
/// Execute a given, serialised, transaction. Returns the empty vector.
pub fn finalise_block(mut input: &[u8]) -> Vec<u8> {
let header = Header::from_slice(&mut input).unwrap();
let header = runtime::system::internal::finalise_block(header);
header.to_vec()
}
/// Run whatever tests we have.
pub fn run_tests(mut input: &[u8]) -> Vec<u8> {
use runtime_std::print;
print("run_tests...");
let block = Block::from_slice(&mut input).unwrap();
print("deserialised block.");
let stxs = block.transactions.iter().map(Slicable::to_vec).collect::<Vec<_>>();
print("reserialised transactions.");
[stxs.len() as u8].to_vec()
}
impl_stubs!(execute_block, execute_transaction, finalise_block, run_tests);