git.delta.rocks / unique-network / refs/commits / 8f7419bc1620

difftreelog

source

pallets/collator-selection/src/weights.rs6.1 KiBsourcehistory
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617// Original license:18// This file is part of Substrate.1920// Copyright (C) 2021 Parity Technologies (UK) Ltd.21// SPDX-License-Identifier: Apache-2.02223// Licensed under the Apache License, Version 2.0 (the "License");24// you may not use this file except in compliance with the License.25// You may obtain a copy of the License at26//27// http://www.apache.org/licenses/LICENSE-2.028//29// Unless required by applicable law or agreed to in writing, software30// distributed under the License is distributed on an "AS IS" BASIS,31// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.32// See the License for the specific language governing permissions and33// limitations under the License.3435#![allow(unused_parens)]36#![allow(unused_imports)]3738use frame_support::{39	traits::Get,40	weights::{constants::RocksDbWeight, Weight},41};42use sp_std::marker::PhantomData;4344// The weight info trait for `pallet_collator_selection`.45pub trait WeightInfo {46	fn set_invulnerables(_b: u32) -> Weight;47	fn set_desired_candidates() -> Weight;48	fn set_candidacy_bond() -> Weight;49	fn register_as_candidate(_c: u32) -> Weight;50	fn leave_intent(_c: u32) -> Weight;51	fn note_author() -> Weight;52	fn new_session(_c: u32, _r: u32) -> Weight;53}5455/// Weights for pallet_collator_selection using the Substrate node and recommended hardware.56pub struct SubstrateWeight<T>(PhantomData<T>);57impl<T: frame_system::Config> WeightInfo for SubstrateWeight<T> {58	fn set_invulnerables(b: u32) -> Weight {59		Weight::from_ref_time(18_563_000 as u64)60			// Standard Error: 061			.saturating_add(Weight::from_ref_time(68_000 as u64).saturating_mul(b as u64))62			.saturating_add(T::DbWeight::get().writes(1 as u64))63	}64	fn set_desired_candidates() -> Weight {65		Weight::from_ref_time(16_363_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))66	}67	fn set_candidacy_bond() -> Weight {68		Weight::from_ref_time(16_840_000 as u64).saturating_add(T::DbWeight::get().writes(1 as u64))69	}70	fn register_as_candidate(c: u32) -> Weight {71		Weight::from_ref_time(71_196_000 as u64)72			// Standard Error: 073			.saturating_add(Weight::from_ref_time(198_000 as u64).saturating_mul(c as u64))74			.saturating_add(T::DbWeight::get().reads(4 as u64))75			.saturating_add(T::DbWeight::get().writes(2 as u64))76	}77	fn leave_intent(c: u32) -> Weight {78		Weight::from_ref_time(55_336_000 as u64)79			// Standard Error: 080			.saturating_add(Weight::from_ref_time(151_000 as u64).saturating_mul(c as u64))81			.saturating_add(T::DbWeight::get().reads(1 as u64))82			.saturating_add(T::DbWeight::get().writes(2 as u64))83	}84	fn note_author() -> Weight {85		Weight::from_ref_time(71_461_000 as u64)86			.saturating_add(T::DbWeight::get().reads(3 as u64))87			.saturating_add(T::DbWeight::get().writes(4 as u64))88	}89	fn new_session(r: u32, c: u32) -> Weight {90		Weight::from_ref_time(0 as u64)91			// Standard Error: 1_010_00092			.saturating_add(Weight::from_ref_time(109_961_000 as u64).saturating_mul(r as u64))93			// Standard Error: 1_010_00094			.saturating_add(Weight::from_ref_time(151_952_000 as u64).saturating_mul(c as u64))95			.saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(r as u64)))96			.saturating_add(T::DbWeight::get().reads((2 as u64).saturating_mul(c as u64)))97			.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(r as u64)))98			.saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(c as u64)))99	}100}101102// For backwards compatibility and tests103impl WeightInfo for () {104	fn set_invulnerables(b: u32) -> Weight {105		Weight::from_ref_time(18_563_000 as u64)106			// Standard Error: 0107			.saturating_add(Weight::from_ref_time(68_000 as u64).saturating_mul(b as u64))108			.saturating_add(RocksDbWeight::get().writes(1 as u64))109	}110	fn set_desired_candidates() -> Weight {111		Weight::from_ref_time(16_363_000 as u64)112			.saturating_add(RocksDbWeight::get().writes(1 as u64))113	}114	fn set_candidacy_bond() -> Weight {115		Weight::from_ref_time(16_840_000 as u64)116			.saturating_add(RocksDbWeight::get().writes(1 as u64))117	}118	fn register_as_candidate(c: u32) -> Weight {119		Weight::from_ref_time(71_196_000 as u64)120			// Standard Error: 0121			.saturating_add(Weight::from_ref_time(198_000 as u64).saturating_mul(c as u64))122			.saturating_add(RocksDbWeight::get().reads(4 as u64))123			.saturating_add(RocksDbWeight::get().writes(2 as u64))124	}125	fn leave_intent(c: u32) -> Weight {126		Weight::from_ref_time(55_336_000 as u64)127			// Standard Error: 0128			.saturating_add(Weight::from_ref_time(151_000 as u64).saturating_mul(c as u64))129			.saturating_add(RocksDbWeight::get().reads(1 as u64))130			.saturating_add(RocksDbWeight::get().writes(2 as u64))131	}132	fn note_author() -> Weight {133		Weight::from_ref_time(71_461_000 as u64)134			.saturating_add(RocksDbWeight::get().reads(3 as u64))135			.saturating_add(RocksDbWeight::get().writes(4 as u64))136	}137	fn new_session(r: u32, c: u32) -> Weight {138		Weight::from_ref_time(0 as u64)139			// Standard Error: 1_010_000140			.saturating_add(Weight::from_ref_time(109_961_000 as u64).saturating_mul(r as u64))141			// Standard Error: 1_010_000142			.saturating_add(Weight::from_ref_time(151_952_000 as u64).saturating_mul(c as u64))143			.saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(r as u64)))144			.saturating_add(RocksDbWeight::get().reads((2 as u64).saturating_mul(c as u64)))145			.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(r as u64)))146			.saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(c as u64)))147	}148}