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
!109
feat(genesis): allow genesis certs with custom expiration time
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
feat(genesis): allow genesis certs with custom expiration time
elois-gen-cert-type
into
master
Overview
0
Commits
1
Pipelines
0
Changes
1
Merged
Éloïs
requested to merge
elois-gen-cert-type
into
master
2 years ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
e93c49b2
Show latest version
1 file
+
26
−
9
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
e93c49b2
feat(genesis): allow genesis certs with custom expiration time
· e93c49b2
Éloïs
authored
2 years ago
node/src/chain_spec/gen_genesis_data.rs
+
26
−
9
Options
@@ -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
);
Loading