Skip to content
Snippets Groups Projects
Commit 78898195 authored by bgallois's avatar bgallois Committed by Hugo Trentesaux
Browse files

refactor functions naming for pallet-certification

parent 5620ee33
No related branches found
No related tags found
1 merge request!197Eliminate all Instances of `Weight::zero()`
......@@ -82,9 +82,9 @@ benchmarks_instance_pallet! {
on_initialize {
assert!(StorageCertsRemovableOn::<T, I>::try_get(T::BlockNumber::zero()).is_err());
}: {Pallet::<T, I>::on_initialize(T::BlockNumber::zero());}
remove_cert_inner_noop {
}: {Pallet::<T, I>::remove_cert_inner(100.into(), 101.into(), Some(T::BlockNumber::zero()));}
remove_cert_inner {
do_remove_cert_noop {
}: {Pallet::<T, I>::do_remove_cert(100.into(), 101.into(), Some(T::BlockNumber::zero()));}
do_remove_cert {
let issuer: T::IdtyIndex = 1.into();
let receiver: T::IdtyIndex = 0.into();
Pallet::<T, I>::do_add_cert_checked(issuer, receiver, false)?;
......@@ -92,7 +92,7 @@ benchmarks_instance_pallet! {
let receiver_cert: u32 = StorageIdtyCertMeta::<T, I>::get(receiver).received_count;
let block_number = T::ValidityPeriod::get();
frame_system::pallet::Pallet::<T>::set_block_number(block_number);
}: {Pallet::<T, I>::remove_cert_inner(issuer, receiver, Some(block_number));}
}: {Pallet::<T, I>::do_remove_cert(issuer, receiver, Some(block_number));}
verify {
assert_has_event::<T, I>(Event::<T, I>::RemovedCert{ issuer: issuer, issuer_issued_count: issuer_cert - 1, receiver: receiver, receiver_received_count: receiver_cert - 1, expiration: true }.into());
}
......
......@@ -334,7 +334,7 @@ pub mod pallet {
receiver: T::IdtyIndex,
) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
Self::remove_cert_inner(issuer, receiver, None);
Self::do_remove_cert(issuer, receiver, None);
Ok(().into())
}
......@@ -347,7 +347,7 @@ pub mod pallet {
) -> DispatchResultWithPostInfo {
ensure_root(origin)?;
for (issuer, _) in CertsByReceiver::<T, I>::get(idty_index) {
Self::remove_cert_inner(issuer, idty_index, None);
Self::do_remove_cert(issuer, idty_index, None);
}
Ok(().into())
}
......@@ -469,7 +469,7 @@ pub mod pallet {
if let Some(certs) = StorageCertsRemovableOn::<T, I>::take(block_number) {
for (issuer, receiver) in certs {
total_weight += Self::remove_cert_inner(issuer, receiver, Some(block_number));
total_weight += Self::do_remove_cert(issuer, receiver, Some(block_number));
}
}
......@@ -477,7 +477,7 @@ pub mod pallet {
}
/// perform the certification removal
/// if block number is given only remove cert if still set to expire at this block number
pub fn remove_cert_inner(
pub fn do_remove_cert(
issuer: T::IdtyIndex,
receiver: T::IdtyIndex,
block_number_opt: Option<T::BlockNumber>,
......@@ -500,7 +500,7 @@ pub mod pallet {
removed = true;
}
} else {
total_weight += T::WeightInfo::remove_cert_inner_noop();
total_weight += T::WeightInfo::do_remove_cert_noop();
}
});
if removed {
......@@ -534,7 +534,7 @@ pub mod pallet {
// Pessimistic overhead estimation based on the worst path of a successfull
// certificate removal to avoid multiplying benchmarks for every branching,
// include the OnRemovedCert weight.
total_weight.saturating_add(T::WeightInfo::remove_cert_inner());
total_weight.saturating_add(T::WeightInfo::do_remove_cert());
}
total_weight
}
......
......@@ -24,8 +24,8 @@ pub trait WeightInfo {
fn del_cert() -> Weight;
fn remove_all_certs_received_by(i: u32) -> Weight;
fn on_initialize() -> Weight;
fn remove_cert_inner_noop() -> Weight;
fn remove_cert_inner() -> Weight;
fn do_remove_cert_noop() -> Weight;
fn do_remove_cert() -> Weight;
}
// Insecure weights implementation, use it for tests only!
......@@ -72,13 +72,13 @@ impl WeightInfo for () {
.saturating_add(RocksDbWeight::get().reads(7 as u64))
.saturating_add(RocksDbWeight::get().writes(4 as u64))
}
fn remove_cert_inner_noop() -> Weight {
fn do_remove_cert_noop() -> Weight {
// Minimum execution time: 259_247 nanoseconds.
Weight::from_parts(269_348_000 as u64, 0)
.saturating_add(RocksDbWeight::get().reads(7 as u64))
.saturating_add(RocksDbWeight::get().writes(4 as u64))
}
fn remove_cert_inner() -> Weight {
fn do_remove_cert() -> Weight {
// Minimum execution time: 259_247 nanoseconds.
Weight::from_parts(269_348_000 as u64, 0)
.saturating_add(RocksDbWeight::get().reads(7 as u64))
......
......@@ -111,7 +111,7 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T>
}
/// Storage: Cert CertsByReceiver (r:1 w:1)
/// Proof Skipped: Cert CertsByReceiver (max_values: None, max_size: None, mode: Measured)
fn remove_cert_inner_noop() -> Weight {
fn do_remove_cert_noop() -> Weight {
// Proof Size summary in bytes:
// Measured: `279`
// Estimated: `3744`
......@@ -129,7 +129,7 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T>
/// Proof Skipped: Parameters ParametersStorage (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: Membership Membership (r:1 w:0)
/// Proof Skipped: Membership Membership (max_values: None, max_size: None, mode: Measured)
fn remove_cert_inner() -> Weight {
fn do_remove_cert() -> Weight {
// Proof Size summary in bytes:
// Measured: `722`
// Estimated: `6662`
......
......@@ -111,7 +111,7 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T>
}
/// Storage: SmithCert CertsByReceiver (r:1 w:1)
/// Proof Skipped: SmithCert CertsByReceiver (max_values: None, max_size: None, mode: Measured)
fn remove_cert_inner_noop() -> Weight {
fn do_remove_cert_noop() -> Weight {
// Proof Size summary in bytes:
// Measured: `235`
// Estimated: `3700`
......@@ -129,7 +129,7 @@ impl<T: frame_system::Config> pallet_certification::WeightInfo for WeightInfo<T>
/// Proof Skipped: Parameters ParametersStorage (max_values: Some(1), max_size: None, mode: Measured)
/// Storage: SmithMembership Membership (r:1 w:0)
/// Proof Skipped: SmithMembership Membership (max_values: None, max_size: None, mode: Measured)
fn remove_cert_inner() -> Weight {
fn do_remove_cert() -> Weight {
// Proof Size summary in bytes:
// Measured: `638`
// Estimated: `6578`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment