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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
rust
Duniter v2S
Commits
e93c49b2
Commit
e93c49b2
authored
2 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
feat(genesis): allow genesis certs with custom expiration time
parent
e585ab59
No related branches found
No related tags found
1 merge request
!109
feat(genesis): allow genesis certs with custom expiration time
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
node/src/chain_spec/gen_genesis_data.rs
+26
-9
26 additions, 9 deletions
node/src/chain_spec/gen_genesis_data.rs
with
26 additions
and
9 deletions
node/src/chain_spec/gen_genesis_data.rs
+
26
−
9
View file @
e93c49b2
...
...
@@ -70,7 +70,7 @@ struct Idty {
#[serde(default)]
balance
:
u64
,
#[serde(default)]
certs
:
Vec
<
String
>
,
certs
:
Vec
<
Cert
>
,
#[serde(rename
=
"expire_on"
)]
membership_expire_on
:
Option
<
u64
>
,
pubkey
:
AccountId
,
...
...
@@ -80,7 +80,22 @@ struct Idty {
struct
SmithData
{
session_keys
:
Option
<
String
>
,
#[serde(default)]
certs
:
Vec
<
String
>
,
certs
:
Vec
<
Cert
>
,
}
#[derive(Clone,
Deserialize,
Serialize)]
#[serde(untagged)]
enum
Cert
{
Issuer
(
String
),
IssuerAndExpireOn
(
String
,
u32
),
}
impl
From
<
Cert
>
for
(
String
,
Option
<
u32
>
)
{
fn
from
(
cert
:
Cert
)
->
Self
{
match
cert
{
Cert
::
Issuer
(
issuer
)
=>
(
issuer
,
None
),
Cert
::
IssuerAndExpireOn
(
issuer
,
expire_on
)
=>
(
issuer
,
Some
(
expire_on
)),
}
}
}
pub
fn
generate_genesis_data
<
CS
,
P
,
SK
,
F
>
(
...
...
@@ -229,11 +244,12 @@ where
.get
(
&
idty_name
)
.ok_or
(
format!
(
"Identity '{}' not exist"
,
&
idty_name
))
?
;
let
mut
receiver_certs
=
BTreeMap
::
new
();
for
issuer
in
&
identity
.certs
{
for
cert
in
&
identity
.certs
{
let
(
issuer
,
maybe_expire_on
)
=
cert
.clone
()
.into
();
let
issuer_index
=
idty_index_of
.get
(
issuer
)
.get
(
&
issuer
)
.ok_or
(
format!
(
"Identity '{}' not exist"
,
issuer
))
?
;
receiver_certs
.insert
(
*
issuer_index
,
N
on
e
);
receiver_certs
.insert
(
*
issuer_index
,
maybe_expire_
on
);
}
certs_by_receiver
.insert
(
*
issuer_index
,
receiver_certs
);
}
...
...
@@ -311,11 +327,12 @@ where
// Certifications
let
mut
receiver_certs
=
BTreeMap
::
new
();
for
receiver
in
&
smith_data
.certs
{
for
cert
in
&
smith_data
.certs
{
let
(
issuer
,
maybe_expire_on
)
=
cert
.clone
()
.into
();
let
issuer_index
=
idty_index_of
.get
(
receiv
er
)
.ok_or
(
format!
(
"Identity '{}' not exist"
,
receiv
er
))
?
;
receiver_certs
.insert
(
*
issuer_index
,
N
on
e
);
.get
(
&
issu
er
)
.ok_or
(
format!
(
"Identity '{}' not exist"
,
issu
er
))
?
;
receiver_certs
.insert
(
*
issuer_index
,
maybe_expire_
on
);
}
smiths_certs_by_receiver
.insert
(
*
idty_index
,
receiver_certs
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment