replace some encode by using_encoded (#1863)

* replace some encode by using_encoded

* update runtime

* improve readibility
This commit is contained in:
thiolliere
2019-02-26 09:26:11 +01:00
committed by Bastian Köcher
parent 34fccecc02
commit 72a8927ea3
4 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -61,7 +61,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
impl_name: create_runtime_str!("substrate-node"),
authoring_version: 10,
spec_version: 30,
impl_version: 31,
impl_version: 32,
apis: RUNTIME_API_VERSIONS,
};
+2 -2
View File
@@ -69,7 +69,7 @@ use crate::account_db::AccountDb;
use serde_derive::{Serialize, Deserialize};
use rstd::prelude::*;
use rstd::marker::PhantomData;
use parity_codec::Codec;
use parity_codec::{Codec, Encode};
use parity_codec_derive::{Encode, Decode};
use runtime_primitives::traits::{Hash, As, SimpleArithmetic,Bounded, StaticLookup};
use srml_support::dispatch::{Result, Dispatchable};
@@ -140,7 +140,7 @@ where
pub struct DefaultDispatchFeeComputor<T: Trait>(PhantomData<T>);
impl<T: Trait> ComputeDispatchFee<T::Call, T::Balance> for DefaultDispatchFeeComputor<T> {
fn compute_dispatch_fee(call: &T::Call) -> T::Balance {
let encoded_len = parity_codec::Encode::encode(&call).len();
let encoded_len = call.using_encoded(|encoded| encoded.len());
let base_fee = <fees::Module<T>>::transaction_base_fee();
let byte_fee = <fees::Module<T>>::transaction_byte_fee();
<T::Balance as As<u64>>::sa(base_fee.as_() + byte_fee.as_() * encoded_len as u64)
+1 -1
View File
@@ -101,7 +101,7 @@ pub trait StorageDoubleMap {
{
let mut raw_prefix = Vec::new();
raw_prefix.extend(Self::PREFIX);
raw_prefix.extend(Encode::encode(&key));
key.encode_to(&mut raw_prefix);
raw_prefix
}