mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Weights to u64 + Balances Weights (#5446)
Co-Authored-By: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
use frame_support::{decl_module, decl_storage, decl_event, decl_error};
|
||||
use frame_support::weights::{SimpleDispatchInfo, MINIMUM_WEIGHT};
|
||||
use frame_support::traits::Currency;
|
||||
use frame_system::{self as system, ensure_signed};
|
||||
use codec::{Encode, Decode};
|
||||
@@ -70,7 +71,7 @@ decl_module! {
|
||||
fn deposit_event() = default;
|
||||
|
||||
/// Do nothing.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn do_nothing(_origin, input: u32) {
|
||||
if input > 0 {
|
||||
return Ok(());
|
||||
@@ -82,7 +83,7 @@ decl_module! {
|
||||
/// storage database, however, the `repeat` calls will all pull from the
|
||||
/// storage overlay cache. You must consider this when analyzing the
|
||||
/// results of the benchmark.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn read_value(_origin, repeat: u32) {
|
||||
for _ in 0..repeat {
|
||||
MyValue::get();
|
||||
@@ -90,7 +91,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Put a value into a storage value.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn put_value(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyValue::put(r);
|
||||
@@ -102,7 +103,7 @@ decl_module! {
|
||||
/// storage database, however, the `repeat` calls will all pull from the
|
||||
/// storage overlay cache. You must consider this when analyzing the
|
||||
/// results of the benchmark.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn exists_value(_origin, repeat: u32) {
|
||||
for _ in 0..repeat {
|
||||
MyValue::exists();
|
||||
@@ -110,7 +111,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Remove a value from storage `repeat` number of times.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn remove_value(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyMap::remove(r);
|
||||
@@ -118,7 +119,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Read a value from storage map `repeat` number of times.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn read_map(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyMap::get(r);
|
||||
@@ -126,7 +127,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Insert a value into a map.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn insert_map(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyMap::insert(r, r);
|
||||
@@ -134,7 +135,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Check is a map contains a value `repeat` number of times.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn contains_key_map(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyMap::contains_key(r);
|
||||
@@ -142,7 +143,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Read a value from storage `repeat` number of times.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn remove_prefix(_origin, repeat: u32) {
|
||||
for r in 0..repeat {
|
||||
MyDoubleMap::remove_prefix(r);
|
||||
@@ -150,21 +151,21 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Add user to the list.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn add_member_list(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
MyMemberList::<T>::mutate(|x| x.push(who));
|
||||
}
|
||||
|
||||
/// Append user to the list.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn append_member_list(origin) {
|
||||
let who = ensure_signed(origin)?;
|
||||
MyMemberList::<T>::append(&[who])?;
|
||||
}
|
||||
|
||||
/// Encode a vector of accounts to bytes.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn encode_accounts(_origin, accounts: Vec<T::AccountId>) {
|
||||
let bytes = accounts.encode();
|
||||
|
||||
@@ -176,7 +177,7 @@ decl_module! {
|
||||
}
|
||||
|
||||
/// Decode bytes into a vector of accounts.
|
||||
#[weight = frame_support::weights::SimpleDispatchInfo::default()]
|
||||
#[weight = SimpleDispatchInfo::FixedNormal(MINIMUM_WEIGHT)]
|
||||
pub fn decode_accounts(_origin, bytes: Vec<u8>) {
|
||||
let accounts: Vec<T::AccountId> = Decode::decode(&mut bytes.as_slice()).map_err(|_| "Could not decode")?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user