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
Commits
72bad860
Unverified
Commit
72bad860
authored
7 months ago
by
bgallois
Browse files
Options
Downloads
Patches
Plain Diff
fix
#255
parent
6018f90d
No related branches found
No related tags found
1 merge request
!284
Fix #255 distance reading discarded state
Pipeline
#38239
passed
7 months ago
Stage: labels
Stage: quality
Stage: build
Stage: tests
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/distance/src/lib.rs
+28
-16
28 additions, 16 deletions
client/distance/src/lib.rs
with
28 additions
and
16 deletions
client/distance/src/lib.rs
+
28
−
16
View file @
72bad860
...
@@ -40,18 +40,30 @@ where
...
@@ -40,18 +40,30 @@ where
Backend
:
sc_client_api
::
Backend
<
B
>
,
Backend
:
sc_client_api
::
Backend
<
B
>
,
IdtyIndex
:
Decode
+
Encode
+
PartialEq
+
TypeInfo
,
IdtyIndex
:
Decode
+
Encode
+
PartialEq
+
TypeInfo
,
{
{
// Retrieve the pool_index from storage. If storage is inaccessible or the data is corrupted,
// return the appropriate error.
let
pool_index
=
client
let
pool_index
=
client
.storage
(
.storage
(
parent
,
parent
,
&
StorageKey
(
&
StorageKey
(
frame_support
::
storage
::
storage_prefix
(
b"Distance"
,
b"CurrentPoolIndex"
)
.to_vec
(),
frame_support
::
storage
::
storage_prefix
(
b"Distance"
,
b"CurrentPoolIndex"
)
.to_vec
(),
),
),
)
)
?
.expect
(
"CurrentIndex is Err"
)
.map_or_else
(
.map_or
(
0
,
|
raw
|
{
||
{
u32
::
decode
(
&
mut
&
raw
.0
[
..
])
.expect
(
"cannot decode CurrentIndex"
)
Err
(
sc_client_api
::
blockchain
::
Error
::
Storage
(
});
"CurrentPoolIndex value not found"
.to_string
(),
))
},
|
raw
|
{
u32
::
decode
(
&
mut
&
raw
.0
[
..
])
.map_err
(|
e
|
sc_client_api
::
blockchain
::
Error
::
from_state
(
Box
::
new
(
e
)))
},
)
?
;
// Retrieve the published_results from storage.
// Return an error if the storage is inaccessible.
// If accessible, continue execution. If None, it means there are no published_results at this block.
let
published_results
=
client
let
published_results
=
client
.storage
(
.storage
(
parent
,
parent
,
...
@@ -68,22 +80,22 @@ where
...
@@ -68,22 +80,22 @@ where
.to_vec
(),
.to_vec
(),
),
),
)
?
)
?
.map_or_else
(
Default
::
default
,
|
raw
|
{
.and_then
(|
raw
|
{
pallet_distance
::
EvaluationPool
::
<
AccountId32
,
IdtyIndex
>
::
decode
(
&
mut
&
raw
.0
[
..
])
pallet_distance
::
EvaluationPool
::
<
AccountId32
,
IdtyIndex
>
::
decode
(
&
mut
&
raw
.0
[
..
])
.ok
()
.expect
(
"cannot decode EvaluationPool"
)
});
});
// Have we already published a result for this period?
// Have we already published a result for this period?
// The block author is guaranteed to be in the owner_keys.
// The block author is guaranteed to be in the owner_keys.
let
owner_keys
=
owner_keys
if
let
Some
(
results
)
=
published_results
{
if
owner_keys
.iter
()
.iter
()
.map
(|
&
key
|
sp_runtime
::
AccountId32
::
new
(
key
.0
))
.map
(|
&
key
|
sp_runtime
::
AccountId32
::
new
(
key
.0
))
.any
(|
key
|
published_results
.evaluators
.contains
(
&
key
));
.any
(|
key
|
results
.evaluators
.contains
(
&
key
))
{
if
owner_keys
{
log
::
debug!
(
"🧙 [distance oracle] Already published a result for this period"
);
log
::
debug!
(
"🧙 [distance oracle] Already published a result for this period"
);
return
Ok
(
sp_distance
::
InherentDataProvider
::
<
IdtyIndex
>
::
new
(
None
));
return
Ok
(
sp_distance
::
InherentDataProvider
::
<
IdtyIndex
>
::
new
(
None
));
}
}
}
// Read evaluation result from file, if it exists
// Read evaluation result from file, if it exists
log
::
debug!
(
log
::
debug!
(
...
...
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