Commit a307f4aa authored by Hero Bird's avatar Hero Bird
Browse files

[pdsl_core] Make use of new memory module in the rest of the crate

parent 79928952
......@@ -33,9 +33,10 @@ mod srml_env;
#[cfg(feature = "test-env")]
mod test_env;
use crate::storage::Key;
use alloc::vec::Vec;
use crate::{
storage::Key,
memory::vec::Vec
};
/// The evironment API usable by SRML contracts.
pub trait Env {
......
......@@ -16,7 +16,7 @@
use super::*;
use alloc::vec::Vec;
use crate::memory::vec::Vec;
/// Refer to substrate SRML contract module for more documentation.
pub mod c_abi {
......
......@@ -17,9 +17,7 @@
use super::*;
use core::cell::{Cell, RefCell};
use hashbrown::HashMap;
use hashbrown::hash_map::Entry;
use crate::memory::collections::hash_map::{HashMap, Entry};
/// An entry in the storage of the test environment.
///
......
......@@ -15,6 +15,7 @@
// along with pDSL. If not, see <http://www.gnu.org/licenses/>.
use crate::{
memory::vec::Vec,
storage::{
Key,
NonCloneMarker,
......@@ -24,7 +25,6 @@ use crate::{
};
use parity_codec_derive::{Encode, Decode};
use alloc::vec::Vec;
/// A raw cell.
///
......
......@@ -15,6 +15,7 @@
// along with pDSL. If not, see <http://www.gnu.org/licenses/>.
use crate::{
memory::vec::Vec,
storage::{
Key,
NonCloneMarker,
......@@ -22,7 +23,6 @@ use crate::{
},
env::{Env, ContractEnv},
};
use alloc::vec::Vec;
/// A chunk of raw cells.
///
......
......@@ -23,17 +23,17 @@ use crate::{
},
Allocator,
},
};
use core::cell::RefCell;
use hashbrown::{
HashMap,
hash_map::{
memory::collections::hash_map::{
HashMap,
Entry,
DefaultHashBuilder,
},
};
#[cfg(not(feature = "std"))]
use crate::memory::collections::hash_map::DefaultHashBuilder;
use core::cell::RefCell;
/// A chunk of synchronized cells.
///
/// Provides mutable and read-optimized access to the associated constract storage slot.
......@@ -55,8 +55,13 @@ pub struct SyncChunk<T> {
}
/// A single cache entry for a copy chunk cell.
#[cfg(not(feature = "std"))]
type CacheEntry<'a, T> = Entry<'a, u32, Option<T>, DefaultHashBuilder>;
/// A single cache entry for a copy chunk cell.
#[cfg(feature = "std")]
type CacheEntry<'a, T> = Entry<'a, u32, Option<T>>;
/// A single cell within a chunk of copy cells.
#[derive(Debug)]
pub struct SyncChunkCell<'a, T> {
......@@ -242,7 +247,7 @@ impl<T> Cache<T> {
///
/// Returns an immutable reference to the new value.
pub fn upsert(&self, n: u32, val: Option<T>) -> Option<&T> {
use hashbrown::hash_map::{Entry};
use crate::memory::collections::hash_map::Entry;
let elems: &mut HashMap<u32, Option<T>> = unsafe {
&mut *self.elems.as_ptr()
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment