Commit 44c011c4 authored by Hero Bird's avatar Hero Bird
Browse files

[pdsl_core] Use new parity-codec derive forwarding feature

parent bc78aae8
......@@ -19,7 +19,6 @@ include = ["/Cargo.toml", "src/**/*.rs", "/README.md", "/LICENSE"]
[dependencies]
parity-codec = { version = "2.0.4", default-features = false }
parity-codec-derive = { version = "2.0.4", default-features = false }
hashbrown = { version = "0.1.7", features = ["nightly"] }
tiny-keccak = "1.4"
log = "0.4"
......
......@@ -22,7 +22,7 @@ use crate::{
},
};
use parity_codec_derive::{Encode, Decode};
use parity_codec::{Encode, Decode};
const CC_ALLOC_LOG_TARGET: &'static str = "cc_alloc";
......
......@@ -24,7 +24,7 @@ use crate::{
env::{Env, ContractEnv},
};
use parity_codec_derive::{Encode, Decode};
use parity_codec::{Encode, Decode};
/// A raw cell.
///
......@@ -35,8 +35,7 @@ use parity_codec_derive::{Encode, Decode};
/// - `Owned`
///
/// Read more about kinds of guarantees and their effect [here](../index.html#guarantees).
#[derive(Debug, PartialEq, Eq, Hash)]
#[derive(Encode, Decode)]
#[derive(Debug, PartialEq, Eq, Hash, Encode, Decode)]
pub struct RawCell {
/// The key to the associated constract storage slot.
key: Key,
......
......@@ -62,7 +62,7 @@ pub struct HashMap<K, V> {
/// or represent an entry that was removed after it
/// has been occupied with key and value.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(parity_codec_derive::Encode, parity_codec_derive::Decode)]
#[derive(parity_codec::Encode, parity_codec::Decode)]
pub enum Entry<K, V> {
/// An occupied slot with a key and a value.
Occupied(OccupiedEntry<K, V>),
......@@ -72,7 +72,7 @@ pub enum Entry<K, V> {
/// An occupied entry of a storage map.
#[derive(Debug, Clone, PartialEq, Eq)]
#[derive(parity_codec_derive::Encode, parity_codec_derive::Decode)]
#[derive(parity_codec::Encode, parity_codec::Decode)]
pub struct OccupiedEntry<K, V> {
/// The entry's key.
key: K,
......
......@@ -21,7 +21,7 @@ use crate::storage::{
Allocator,
};
use parity_codec_derive::{Encode, Decode};
use parity_codec::{Encode, Decode};
/// A stash collection.
///
......
// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of pDSL.
//
// pDSL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// pDSL is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with pDSL. If not, see <http://www.gnu.org/licenses/>.
/// Types that are able to flush their state into the contract storage.
///
/// # Note
///
/// Many types support caching of their state into memory to avoid costly
/// contract storage reads or writes. When execution of a contract is finished
/// or interrupted (e.g. due to calling a remote contract) we have to flush
/// all cached state into the contract storage.
///
/// # Implementation Hints
///
/// Caching types provided by pDSL are `SyncCell` for caching of a single data
/// and `SyncChunk` for caching an array of data.
///
/// All abstractions built upon them that do not have their own caching mechanism
/// shall simply forward flushing to their interiors. Examples for this are
/// `storage::Vec` or `storage::Value`.
pub trait Flush {
/// Flushes the cached state back to the contract storage, if any.
fn flush();
}
......@@ -16,7 +16,7 @@
use crate::byte_utils;
use parity_codec_derive::{Encode, Decode};
use parity_codec::{Encode, Decode};
const KEY_LOG_TARGET: &'static str = "key";
......@@ -36,8 +36,7 @@ const KEY_LOG_TARGET: &'static str = "key";
/// - Violates Rust's mutability and immutability guarantees.
///
/// Prefer using types found in `collections` or `Synced` type.
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Encode, Decode)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Encode, Decode)]
pub struct Key(pub [u8; 32]);
impl core::fmt::Debug for Key {
......
......@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with pDSL. If not, see <http://www.gnu.org/licenses/>.
use parity_codec_derive::{Encode, Decode};
use parity_codec::{Encode, Decode};
use core::marker::PhantomData;
......@@ -29,8 +29,7 @@ use core::marker::PhantomData;
/// - Especially for `Cell` types it is important to make them
/// non-`Copy` and non-`Clone` since that would violate their
/// ownership guarantees over their contract storage slot.
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Encode, Decode)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Encode, Decode)]
pub struct NonCloneMarker<T>(PhantomData<T>);
impl<T> Default for NonCloneMarker<T> {
......
......@@ -21,8 +21,7 @@ use crate::{
cell::SyncCell,
},
};
use parity_codec_derive::{Encode, Decode};
use parity_codec::{Encode, Decode};
// Missing traits:
//
......
Markdown is supported
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