Transaction eras (#758)

* Initial groundwork

* A mess.

* Integrate

* Fix tests

* Unit tests

* Tests for unchecked_extrisnic

* fix tab

* Improve binary format.

* fix tests

* Rename extrinsic-pool -> transaction-pool

Closes #770

* Implement unimplemented.

* typo
This commit is contained in:
Gav Wood
2018-09-20 14:01:01 +02:00
committed by GitHub
parent 43068f8fc3
commit 67bf1a6eaa
42 changed files with 782 additions and 232 deletions
+34 -6
View File
@@ -60,7 +60,33 @@ pub trait Lookup {
/// Type to lookup into.
type Target;
/// Attempt a lookup.
fn lookup(s: Self::Source) -> result::Result<Self::Target, &'static str>;
fn lookup(&self, s: Self::Source) -> result::Result<Self::Target, &'static str>;
}
/// Get the "current" block number.
pub trait GetHeight {
/// The type of the block number.
type BlockNumber;
/// Return the current block number. Not allowed to fail.
fn get_height(&self) -> Self::BlockNumber;
}
/// Translate a block number into a hash.
pub trait BlockNumberToHash {
/// The type of the block number.
type BlockNumber: Zero;
/// The type of the hash.
type Hash;
/// Get the hash for a given block number, or `None` if unknown.
fn block_number_to_hash(&self, n: Self::BlockNumber) -> Option<Self::Hash>;
/// Get the genesis block hash; this should always be known.
fn genesis_hash(&self) -> Self::Hash {
self.block_number_to_hash(Zero::zero()).expect("All blockchains must know their genesis block hash; qed")
}
}
/// Simple payment making trait, operating on a single generic `AccountId` type.
@@ -407,10 +433,11 @@ pub type NumberFor<B> = <<B as Block>::Header as Header>::Number;
/// Implement for pieces of information that require some additional context `Context` in order to be
/// checked.
pub trait Checkable<Context>: Sized {
/// Returned if `check_with` succeeds.
/// Returned if `check` succeeds.
type Checked;
fn check_with(self, context: Context) -> Result<Self::Checked, &'static str>;
/// Check self, given an instance of Context.
fn check(self, c: &Context) -> Result<Self::Checked, &'static str>;
}
/// A "checkable" piece of information, used by the standard Substrate Executive in order to
@@ -421,13 +448,14 @@ pub trait BlindCheckable: Sized {
/// Returned if `check` succeeds.
type Checked;
/// Check self.
fn check(self) -> Result<Self::Checked, &'static str>;
}
// Every `BlindCheckable` is also a `Checkable` for arbitrary `Context`.
// Every `BlindCheckable` is also a `StaticCheckable` for arbitrary `Context`.
impl<T: BlindCheckable, Context> Checkable<Context> for T {
type Checked = <Self as BlindCheckable>::Checked;
fn check_with(self, _: Context) -> Result<Self::Checked, &'static str> {
fn check(self, _c: &Context) -> Result<Self::Checked, &'static str> {
BlindCheckable::check(self)
}
}
@@ -442,7 +470,7 @@ pub trait Applyable: Sized + Send + Sync {
type AccountId: Member + MaybeDisplay;
type Index: Member + MaybeDisplay + SimpleArithmetic;
type Call: Member;
fn index(&self) -> &Self::Index;
fn index(&self) -> Option<&Self::Index>;
fn sender(&self) -> Option<&Self::AccountId>;
fn deconstruct(self) -> (Self::Call, Option<Self::AccountId>);
}