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
12 files
+ 145
128
Compare changes
  • Side-by-side
  • Inline
Files
12
@@ -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
}
@@ -366,17 +366,13 @@ pub mod pallet {
if verify_rules {
// only verify internal rules if asked
if let Err(e) = Self::check_add_cert_internal(issuer, receiver, block_number) {
sp_std::if_std! {
println!("fail to force add cert: {:?}", e)
}
sp_std::if_std! {println!("fail to force add cert: {:?}", e)}
return T::WeightInfo::do_add_cert_checked();
}
}
if let Err(e) = Self::try_add_cert(block_number, issuer, receiver) {
sp_std::if_std! {
println!("fail to force add cert: {:?}", e)
}
sp_std::if_std! {println!("fail to force add cert: {:?}", e)}
}
T::WeightInfo::do_add_cert_checked()
}
@@ -469,15 +465,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 +526,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