mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-17 17:11:02 +00:00
initial merge
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user