Skip to content
Snippets Groups Projects

Fix weight accounting

Merged Benjamin Gallois requested to merge 167-fix-remove-member-weight into master
Compare and Show latest version
10 files
+ 234
161
Compare changes
  • Side-by-side
  • Inline
Files
10
@@ -342,7 +342,7 @@ pub mod pallet {
pub fn do_remove_all_certs_received_by(idty_index: T::IdtyIndex) -> Weight {
let mut weight = T::DbWeight::get().reads_writes(1, 0);
for (issuer, _) in CertsByReceiver::<T>::get(idty_index) {
weight += Self::do_remove_cert(issuer, idty_index, None);
weight = weight.saturating_add(Self::do_remove_cert(issuer, idty_index, None));
}
weight
}
@@ -469,15 +469,18 @@ pub mod pallet {
// (run at on_initialize step)
fn prune_certifications(block_number: BlockNumberFor<T>) -> Weight {
// See on initialize for the overhead weight accounting
let mut total_weight = Weight::zero();
let mut weight = Weight::zero();
if let Some(certs) = CertsRemovableOn::<T>::take(block_number) {
for (issuer, receiver) in certs {
total_weight += Self::do_remove_cert(issuer, receiver, Some(block_number));
weight = weight.saturating_add(Self::do_remove_cert(
issuer,
receiver,
Some(block_number),
));
}
}
total_weight
weight
}
/// perform the certification removal
@@ -488,7 +491,7 @@ pub mod pallet {
receiver: T::IdtyIndex,
block_number_opt: Option<BlockNumberFor<T>>,
) -> Weight {
let mut total_weight = Weight::zero();
let total_weight = Weight::zero();
let mut removed = false;
CertsByReceiver::<T>::mutate_exists(receiver, |issuers_opt| {
let issuers = issuers_opt.get_or_insert(Vec::with_capacity(0));
@@ -506,7 +509,7 @@ pub mod pallet {
removed = true;
}
} else {
total_weight += T::WeightInfo::do_remove_cert_noop();
total_weight.saturating_add(T::WeightInfo::do_remove_cert_noop());
}
});
if removed {
Loading