Move Externalities into its own crate (#3775)

* Move `Externalities` into `substrate-externalities`

- `Externalities` now support generic extensions
- Split of `primtives-storage` for storage primitive types

* Move the externalities scoping into `substrate-externalities`

* Fix compilation

* Review feedback

* Adds macro for declaring extensions

* Fix benchmarks

* Introduce `ExtensionStore` trait

* Last review comments

* Implement it for `ExtensionStore`
This commit is contained in:
Bastian Köcher
2019-10-09 15:50:30 +02:00
committed by GitHub
parent 984c6ac839
commit 8a39be474e
95 changed files with 1600 additions and 1420 deletions
+6 -5
View File
@@ -17,9 +17,10 @@
use criterion::{Criterion, criterion_group, criterion_main, black_box};
use srml_system as system;
use support::{decl_module, decl_event, impl_outer_origin, impl_outer_event};
use runtime_io::with_externalities;
use primitives::{H256, Blake2Hasher};
use sr_primitives::{Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header};
use primitives::H256;
use sr_primitives::{
set_and_run_with_externalities, Perbill, traits::{BlakeTwo256, IdentityLookup}, testing::Header,
};
mod module {
use super::*;
@@ -82,13 +83,13 @@ impl module::Trait for Runtime {
type Event = Event;
}
fn new_test_ext() -> runtime_io::TestExternalities<Blake2Hasher> {
fn new_test_ext() -> runtime_io::TestExternalities {
system::GenesisConfig::default().build_storage::<Runtime>().unwrap().into()
}
fn deposit_events(n: usize) {
let mut t = new_test_ext();
with_externalities(&mut t, || {
set_and_run_with_externalities(&mut t, || {
for _ in 0..n {
module::Module::<Runtime>::deposit_event(
module::Event::Complex(vec![1, 2, 3], 2, 3, 899)