Skip to content
Snippets Groups Projects
Commit 7ed8892a authored by Cédric Moreau's avatar Cédric Moreau
Browse files

refac(#176): move SmithCertAdded event closer to its storage updates + add docs

parent 5cfcee7d
No related branches found
No related tags found
1 merge request!232Resolve "PromotedToSmith is issued even for Smith"
......@@ -430,6 +430,7 @@ impl<T: Config> Pallet<T> {
}
fn do_certify_smith(receiver: T::IdtyIndex, issuer: T::IdtyIndex) {
// - adds a certification in issuer issued list
Smiths::<T>::mutate(issuer, |maybe_smith_meta| {
if let Some(smith_meta) = maybe_smith_meta {
smith_meta.issued_certs.push(receiver);
......@@ -438,13 +439,19 @@ impl<T: Config> Pallet<T> {
});
Smiths::<T>::mutate(receiver, |maybe_smith_meta| {
if let Some(smith_meta) = maybe_smith_meta {
// - adds a certification in receiver received list
smith_meta.received_certs.push(issuer);
smith_meta.received_certs.sort();
Self::deposit_event(Event::<T>::SmithCertAdded { receiver, issuer });
// - receiving a certification either lead us to Pending or Smith status
let previous_status = smith_meta.status.clone();
smith_meta.status =
if smith_meta.received_certs.len() >= T::MinCertForMembership::get() as usize {
// - if the number of certification received by the receiver is enough, win the Smith status (or keep it)
SmithStatus::Smith
} else {
// - otherwise we are (still) a pending smith
SmithStatus::Pending
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment