More work on Ext & calls.

This commit is contained in:
Gav
2018-02-22 18:38:33 +01:00
parent 38e9d80555
commit d70491f093
3 changed files with 26 additions and 22 deletions
@@ -18,7 +18,7 @@
use rstd::prelude::*; use rstd::prelude::*;
use rstd::cell::RefCell; use rstd::cell::RefCell;
use rstd::hash_map::{HashMap, Entry}; use rstd::collections::hash_map::{HashMap, Entry};
use runtime_io::{print, blake2_256}; use runtime_io::{print, blake2_256};
use codec::KeyedVec; use codec::KeyedVec;
use runtime_support::{storage, StorageVec}; use runtime_support::{storage, StorageVec};
@@ -220,6 +220,7 @@ pub mod public {
let local: RefCell<State> = RefCell::new(HashMap::new()); let local: RefCell<State> = RefCell::new(HashMap::new());
let should_commit = { let should_commit = {
let mut transfer = |inner_dest: &AccountId, value: Balance| {
// Our local ext: Should be used for any transfers and creates that happen internally. // Our local ext: Should be used for any transfers and creates that happen internally.
let ext = Ext { let ext = Ext {
do_get_account_storage: |account: &AccountId, location: &[u8]| do_get_account_storage: |account: &AccountId, location: &[u8]|
@@ -237,7 +238,6 @@ pub mod public {
.unwrap_or_else(|| ext.get_account_balance(account)), .unwrap_or_else(|| ext.get_account_balance(account)),
}; };
let mut transfer = |inner_dest: &AccountId, value: Balance| {
if let Some(commit_state) = effect_transfer(dest, inner_dest, value, ext) { if let Some(commit_state) = effect_transfer(dest, inner_dest, value, ext) {
let mut local = local.borrow_mut(); let mut local = local.borrow_mut();
for (address, (maybe_balance, maybe_code, storage)) in commit_state.into_iter() { for (address, (maybe_balance, maybe_code, storage)) in commit_state.into_iter() {
@@ -259,8 +259,8 @@ pub mod public {
} }
} }
}; };
let mut create = |code: &[u8], value: Balance| unimplemented!(); // TODO: use `create` and place in `local`
let mut create = |code: &[u8], value: Balance| unimplemented!(); let mut set_storage = |code: &[u8], value: Balance| unimplemented!(); // TODO: use `local`
storage::put(CALL_DEPTH, &(call_depth + 1)); storage::put(CALL_DEPTH, &(call_depth + 1));
@@ -25,4 +25,6 @@ pub use std::ptr;
pub use std::rc; pub use std::rc;
pub use std::slice; pub use std::slice;
pub use std::vec; pub use std::vec;
pub mod collections {
pub use std::collections::hash_map; pub use std::collections::hash_map;
}
@@ -25,7 +25,9 @@ extern crate pwasm_alloc;
pub use alloc::boxed; pub use alloc::boxed;
pub use alloc::rc; pub use alloc::rc;
pub use alloc::vec; pub use alloc::vec;
pub mod collections {
pub use alloc::collections::hash_map; pub use alloc::collections::hash_map;
}
pub use core::cell; pub use core::cell;
pub use core::cmp; pub use core::cmp;
pub use core::intrinsics; pub use core::intrinsics;