Remove CallData/OutData.

This commit is contained in:
Gav
2018-02-07 13:02:57 +01:00
parent a5195dfce6
commit 26b4b56402
19 changed files with 197 additions and 103 deletions
@@ -42,6 +42,50 @@ use runtime_std::prelude::*;
use codec::Slicable;
use primitives::relay::{Header, Block, UncheckedTransaction};
/// Type definitions and helpers for transactions.
pub mod transaction {
pub use primitives::relay::{Transaction, UncheckedTransaction};
use primitives::relay::Signature;
#[cfg(feature = "std")]
use std::ops;
#[cfg(not(feature = "std"))]
use core::ops;
/// A type-safe indicator that a transaction has been checked.
#[derive(PartialEq, Eq, Clone)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct CheckedTransaction(UncheckedTransaction);
impl CheckedTransaction {
/// Get a reference to the checked signature.
pub fn signature(&self) -> &Signature {
&self.0.signature
}
}
impl ops::Deref for CheckedTransaction {
type Target = Transaction;
fn deref(&self) -> &Transaction {
&self.0.transaction
}
}
/// Check the signature on a transaction.
///
/// On failure, return the transaction back.
pub fn check(tx: UncheckedTransaction) -> Result<CheckedTransaction, UncheckedTransaction> {
let msg = ::codec::Slicable::to_vec(&tx.transaction);
if ::runtime_std::ed25519_verify(&tx.signature.0, &msg, &tx.transaction.signed) {
Ok(CheckedTransaction(tx))
} else {
Err(tx)
}
}
}
/// Execute a block, with `input` being the canonical serialisation of the block. Returns the
/// empty vector.
pub fn execute_block(mut input: &[u8]) -> Vec<u8> {
@@ -145,7 +145,7 @@ pub mod internal {
}
fn execute_transaction(utx: UncheckedTransaction) {
use runtime_std::transaction;
use ::transaction;
// Verify the signature is good.
let tx = match transaction::check(utx) {