Pruning identities

Duniter has a storage IdentitiesRemovableOn mapping a block number to a list of identities. The identities are added at their creation and removed with prune_identities of the corresponding block if their status did not change (IdtyStatus::Created) and their removable_on field either.

fn prune_identities(block_number: T::BlockNumber) -> Weight {
    let mut total_weight: Weight = 0;

    for (idty_index, idty_status) in IdentitiesRemovableOn::<T>::take(block_number) {
        if let Ok(idty_val) = <Identities<T>>::try_get(idty_index) {
            if idty_val.removable_on == block_number && idty_val.status == idty_status {
                total_weight += Self::do_remove_identity(idty_index)


I might have not well understood how it’s supposed to work, but it seems IdtyStatus::Confirmed do not get pruned this way while I think they should (the idea is to decrease the number of identities that have to be stored and confirmed identity will not be automatically revoked).

Also the removable_on field is useless: it is set to zero when an identity gets validated but does not change otherwise. And for ::Created identities, it is used as a key in IdentitiesRemovableOn.

What I think should be done:

  • remove the removable_on field
  • in prune_identities, allow remove if idty_val.status is ::Created or ::Confirmed

I’ll wait one or two weeks for feedback and submit a MR after this delay if no other piece of understanding is added.