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
7 files
+ 60
41
Compare changes
  • Side-by-side
  • Inline
Files
7
@@ -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
@@ -527,7 +530,6 @@ pub mod pallet {
receiver,
expiration: block_number_opt.is_some(),
});
// Should always return Weight::zero
T::OnRemovedCert::on_removed_cert(
issuer,
issuer_issued_count,
Loading