Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Merge requests
!232
Resolve "PromotedToSmith is issued even for Smith"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "PromotedToSmith is issued even for Smith"
176-promotedtosmith-is-issued-even-for-smith
into
master
Overview
9
Commits
11
Pipelines
13
Changes
2
Merged
Cédric Moreau
requested to merge
176-promotedtosmith-is-issued-even-for-smith
into
master
1 year ago
Overview
9
Commits
11
Pipelines
13
Changes
2
Expand
Closes
#176 (closed)
0
0
Merge request reports
Compare
master
version 5
a4693f4b
1 year ago
version 4
13c6b2c5
1 year ago
version 3
00972dea
1 year ago
version 2
7ad98ce7
1 year ago
version 1
b2927590
1 year ago
master (base)
and
latest version
latest version
8a578852
11 commits,
1 year ago
version 5
a4693f4b
9 commits,
1 year ago
version 4
13c6b2c5
8 commits,
1 year ago
version 3
00972dea
3 commits,
1 year ago
version 2
7ad98ce7
3 commits,
1 year ago
version 1
b2927590
2 commits,
1 year ago
2 files
+
142
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
pallets/smith-members/src/lib.rs
+
22
−
7
Options
@@ -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,25 +439,39 @@ 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
;
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
};
// expiry postponed
let
new_expires_on
=
CurrentSession
::
<
T
>
::
get
()
+
T
::
SmithInactivityMaxDuration
::
get
();
smith_meta
.expires_on
=
Some
(
new_expires_on
);
Self
::
deposit_event
(
Event
::
<
T
>
::
SmithCertAdded
{
receiver
,
issuer
});
if
smith_meta
.status
==
SmithStatus
::
Smith
{
if
previous_status
!=
SmithStatus
::
Smith
{
// - postpone the expiration: a Pending smith cannot do anything but wait
// this postponement is here to ease the process of becoming a smith
let
new_expires_on
=
CurrentSession
::
<
T
>
::
get
()
+
T
::
SmithInactivityMaxDuration
::
get
();
smith_meta
.expires_on
=
Some
(
new_expires_on
);
ExpiresOn
::
<
T
>
::
append
(
new_expires_on
,
receiver
);
}
// - if the status is smith but wasn't, notify that smith gained membership
if
smith_meta
.status
==
SmithStatus
::
Smith
&&
previous_status
!=
SmithStatus
::
Smith
{
Self
::
deposit_event
(
Event
::
<
T
>
::
SmithMembershipAdded
{
idty_index
:
receiver
,
});
}
// TODO: unschedule old expiry
// TODO:
(optimization)
unschedule old expiry
}
});
}
Loading