Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
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
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
a6344150
Commit
a6344150
authored
6 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[fix] blockchain: apply_block: detect wot db corruption
parent
3ed40740
No related branches found
No related tags found
1 merge request
!158
Elois/ws2p v1 requests
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/blockchain/blockchain/src/dubp/apply/mod.rs
+14
-9
14 additions, 9 deletions
lib/modules/blockchain/blockchain/src/dubp/apply/mod.rs
with
14 additions
and
9 deletions
lib/modules/blockchain/blockchain/src/dubp/apply/mod.rs
+
14
−
9
View file @
a6344150
...
@@ -39,8 +39,9 @@ pub struct ValidBlockApplyReqs(
...
@@ -39,8 +39,9 @@ pub struct ValidBlockApplyReqs(
#[derive(Debug,
Copy,
Clone)]
#[derive(Debug,
Copy,
Clone)]
/// ApplyValidBlockError
/// ApplyValidBlockError
pub
enum
ApplyValidBlockError
{
pub
enum
ApplyValidBlockError
{
ExcludeUnknowNodeId
(),
DBsCorrupted
,
RevokeUnknowNodeId
(),
ExcludeUnknowNodeId
,
RevokeUnknowNodeId
,
}
}
pub
fn
apply_valid_block
<
W
:
WebOfTrust
>
(
pub
fn
apply_valid_block
<
W
:
WebOfTrust
>
(
...
@@ -119,7 +120,7 @@ pub fn apply_valid_block<W: WebOfTrust>(
...
@@ -119,7 +120,7 @@ pub fn apply_valid_block<W: WebOfTrust>(
let
wot_id
=
if
let
Some
(
wot_id
)
=
wot_index
.get
(
&
exclusion
)
{
let
wot_id
=
if
let
Some
(
wot_id
)
=
wot_index
.get
(
&
exclusion
)
{
wot_id
wot_id
}
else
{
}
else
{
return
Err
(
ApplyValidBlockError
::
ExcludeUnknowNodeId
()
);
return
Err
(
ApplyValidBlockError
::
ExcludeUnknowNodeId
);
};
};
wot_db
wot_db
.write
(|
db
|
{
.write
(|
db
|
{
...
@@ -136,7 +137,7 @@ pub fn apply_valid_block<W: WebOfTrust>(
...
@@ -136,7 +137,7 @@ pub fn apply_valid_block<W: WebOfTrust>(
let
wot_id
=
if
let
Some
(
wot_id
)
=
wot_index
.get
(
&
compact_revoc
.issuer
)
{
let
wot_id
=
if
let
Some
(
wot_id
)
=
wot_index
.get
(
&
compact_revoc
.issuer
)
{
wot_id
wot_id
}
else
{
}
else
{
return
Err
(
ApplyValidBlockError
::
RevokeUnknowNodeId
()
);
return
Err
(
ApplyValidBlockError
::
RevokeUnknowNodeId
);
};
};
wot_db
wot_db
.write
(|
db
|
{
.write
(|
db
|
{
...
@@ -152,11 +153,15 @@ pub fn apply_valid_block<W: WebOfTrust>(
...
@@ -152,11 +153,15 @@ pub fn apply_valid_block<W: WebOfTrust>(
for
certification
in
&
block
.certifications
{
for
certification
in
&
block
.certifications
{
trace!
(
"stack_up_valid_block: apply cert..."
);
trace!
(
"stack_up_valid_block: apply cert..."
);
let
compact_cert
=
certification
.to_compact_document
();
let
compact_cert
=
certification
.to_compact_document
();
let
wot_node_from
=
wot_index
[
&
compact_cert
.issuer
];
let
wot_node_from
=
wot_index
let
wot_node_to
=
wot_index
[
&
compact_cert
.target
];
.get
(
&
compact_cert
.issuer
)
.ok_or
(
ApplyValidBlockError
::
DBsCorrupted
)
?
;
let
wot_node_to
=
wot_index
.get
(
&
compact_cert
.target
)
.ok_or
(
ApplyValidBlockError
::
DBsCorrupted
)
?
;
wot_db
wot_db
.write
(|
db
|
{
.write
(|
db
|
{
let
result
=
db
.add_link
(
wot_node_from
,
wot_node_to
);
let
result
=
db
.add_link
(
*
wot_node_from
,
*
wot_node_to
);
match
result
{
match
result
{
NewLinkResult
::
Ok
(
_
)
=>
{}
NewLinkResult
::
Ok
(
_
)
=>
{}
_
=>
fatal_error!
(
_
=>
fatal_error!
(
...
@@ -170,8 +175,8 @@ pub fn apply_valid_block<W: WebOfTrust>(
...
@@ -170,8 +175,8 @@ pub fn apply_valid_block<W: WebOfTrust>(
.expect
(
"Fail to write in WotDB"
);
.expect
(
"Fail to write in WotDB"
);
wot_dbs_requests
.push
(
WotsDBsWriteQuery
::
CreateCert
(
wot_dbs_requests
.push
(
WotsDBsWriteQuery
::
CreateCert
(
compact_cert
.issuer
,
compact_cert
.issuer
,
wot_node_from
,
*
wot_node_from
,
wot_node_to
,
*
wot_node_to
,
compact_cert
.block_number
,
compact_cert
.block_number
,
block
.median_time
,
block
.median_time
,
));
));
...
...
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