Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
py-g1-migrator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
tools
py-g1-migrator
Commits
fcdcb138
Commit
fcdcb138
authored
1 year ago
by
Vincent Texier
Browse files
Options
Downloads
Patches
Plain Diff
[fix] fix issued certifications list not updated to their last state
parent
2d6b6b61
No related branches found
No related tags found
1 merge request
!4
import data from Duniter 1.8 leveldb database
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
adapters/duniter_v18/certifications.py
+40
-7
40 additions, 7 deletions
adapters/duniter_v18/certifications.py
lib/functions.py
+7
-5
7 additions, 5 deletions
lib/functions.py
with
47 additions
and
12 deletions
adapters/duniter_v18/certifications.py
+
40
−
7
View file @
fcdcb138
...
@@ -18,28 +18,61 @@ class LevelDBCertificationsRepository:
...
@@ -18,28 +18,61 @@ class LevelDBCertificationsRepository:
def
__iter__
(
self
):
def
__iter__
(
self
):
"""
"""
Iterate over pubkey: str, certifications: dict
Iterate over pubkey: str, issuer: dict
(with issued certifications updated to their last state)
:return:
:return:
"""
"""
for
key
,
value
in
self
.
index
.
__iter__
():
for
key
,
value
in
self
.
index
.
__iter__
():
yield
key
.
decode
(
"
utf-8
"
),
get_
certifications
_from_db_entry
(
value
)
yield
key
.
decode
(
"
utf-8
"
),
get_
issuer
_from_db_entry
(
value
)
def
get
(
self
,
pubkey
:
str
)
->
dict
:
def
get
(
self
,
pubkey
:
str
)
->
dict
:
"""
"""
Return
certifications
dict from pubkey
Return
issuer
dict from pubkey
:param pubkey: Identity account pubkey
:param pubkey: Identity account pubkey
:return:q
:return:q
"""
"""
return
get_certifications_from_db_entry
(
self
.
index
.
get
(
pubkey
.
encode
(
"
utf-8
"
)))
db_entry
=
self
.
index
.
get
(
pubkey
.
encode
(
"
utf-8
"
))
return
get_issuer_from_db_entry
(
db_entry
)
def
get_
certifications
_from_db_entry
(
json_string
:
str
)
->
dict
:
def
get_
issuer
_from_db_entry
(
json_string
:
str
)
->
dict
:
"""
"""
Get certifications dict from json string
Get issuer dict from json string
(with issued certifications updated to their last state)
:param json_string: Json entry
:param json_string: Json entry
:return:
:return:
"""
"""
return
json
.
loads
(
json_string
)
issuer
=
json
.
loads
(
json_string
)
issuer
[
"
issued
"
]
=
get_updated_certifications_from_issuer
(
issuer
[
"
issued
"
])
return
issuer
def
get_updated_certifications_from_issuer
(
issued_certifications
:
list
)
->
list
:
"""
Return certifications from issuer_pubkey
Certifications are updated to the last state for each receiver
:param issued_certifications: Issuer issued certifications list
:return:
"""
issuer_certifications
=
[]
for
cert
in
issued_certifications
:
if
cert
[
"
op
"
]
==
"
CREATE
"
:
receiver_pubkey
=
cert
[
"
receiver
"
]
# filter only certifications to receiver
issuer_to_receiver_certifications
=
[
issuer_certification
for
issuer_certification
in
issued_certifications
if
issuer_certification
[
"
receiver
"
]
==
receiver_pubkey
]
# update first certification properties except for None value
issuer_to_receiver_certification
=
{
key
:
value
for
issuer_certification
in
issuer_to_receiver_certifications
for
(
key
,
value
)
in
issuer_certification
.
items
()
if
value
is
not
None
or
issuer_certification
==
issuer_to_receiver_certifications
[
0
]}
issuer_certifications
.
append
(
issuer_to_receiver_certification
)
return
issuer_certifications
This diff is collapsed.
Click to expand it.
lib/functions.py
+
7
−
5
View file @
fcdcb138
...
@@ -140,11 +140,13 @@ def get_identities_and_wallets(start_timestamp):
...
@@ -140,11 +140,13 @@ def get_identities_and_wallets(start_timestamp):
# Generate identities Ğ1v2 genesis json bloc
# Generate identities Ğ1v2 genesis json bloc
# certs are stored per issuer in input file
# certs are stored per issuer in input file
# certs are stored per receiver in output file
# certs are stored per receiver in output file
print
(
"
parse certification...
"
)
print
(
"
parse certifications...
"
)
# get certifications updated to their last state
for
i_pubkey
,
issuer
in
certifications_repository
:
for
i_pubkey
,
issuer
in
certifications_repository
:
i_uid
=
identity_names
[
i_pubkey
]
i_uid
=
identity_names
[
i_pubkey
]
i_address
=
v1_pubkey_to_v2_address
(
i_pubkey
)
i_address
=
v1_pubkey_to_v2_address
(
i_pubkey
)
# get certifications updated to their last state
for
cert
in
issuer
[
"
issued
"
]:
for
cert
in
issuer
[
"
issued
"
]:
# if certification expired, skip silently
# if certification expired, skip silently
if
cert
[
"
expired_on
"
]
!=
0
:
if
cert
[
"
expired_on
"
]
!=
0
:
...
...
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