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
0f5881c9
Commit
0f5881c9
authored
5 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[fix] blockchain: reset current blockstamp when abort rollback
parent
6fe22179
No related branches found
No related tags found
1 merge request
!193
Resolve "Migrate high-volume DBs to LMDB"
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/modules/blockchain/blockchain/src/fork/rollback.rs
+46
-27
46 additions, 27 deletions
lib/modules/blockchain/blockchain/src/fork/rollback.rs
with
46 additions
and
27 deletions
lib/modules/blockchain/blockchain/src/fork/rollback.rs
+
46
−
27
View file @
0f5881c9
...
@@ -88,15 +88,16 @@ pub fn apply_rollback(bc: &mut BlockchainModule, new_bc_branch: Vec<Blockstamp>)
...
@@ -88,15 +88,16 @@ pub fn apply_rollback(bc: &mut BlockchainModule, new_bc_branch: Vec<Blockstamp>)
durs_bc_db_reader
::
blocks
::
get_fork_block
(
&
db
,
w
.as_ref
(),
*
blockstamp
)
durs_bc_db_reader
::
blocks
::
get_fork_block
(
&
db
,
w
.as_ref
(),
*
blockstamp
)
{
{
new_branch_blocks
.push
(
dal_block
.clone
());
new_branch_blocks
.push
(
dal_block
.clone
());
if
let
Ok
(
CheckAndApplyBlockReturn
::
ValidMainBlock
(
ValidBlockApplyReqs
(
match
check_and_apply_block
(
bc
,
&
db
,
&
mut
w
,
dal_block
.block
)
{
Ok
(
check_and_apply_block_return
)
=>
match
check_and_apply_block_return
{
CheckAndApplyBlockReturn
::
ValidMainBlock
(
ValidBlockApplyReqs
(
bc_db_query
,
bc_db_query
,
wot_dbs_queries
,
wot_dbs_queries
,
tx_dbs_queries
,
tx_dbs_queries
,
)))
=
check_and_apply_block
(
bc
,
&
db
,
&
mut
w
,
dal_block
.block
)
))
=>
{
{
bc
.current_blockstamp
=
*
blockstamp
;
bc
.current_blockstamp
=
*
blockstamp
;
// Apply db requests
// Apply db requests
bc_db_query
bc_db_query
.apply
(
.apply
(
&
db
,
&
db
,
...
@@ -112,11 +113,27 @@ pub fn apply_rollback(bc: &mut BlockchainModule, new_bc_branch: Vec<Blockstamp>)
...
@@ -112,11 +113,27 @@ pub fn apply_rollback(bc: &mut BlockchainModule, new_bc_branch: Vec<Blockstamp>)
.expect
(
"Fatal error : Fail to apply WotsDBsWriteRequest !"
);
.expect
(
"Fatal error : Fail to apply WotsDBsWriteRequest !"
);
}
}
exec_currency_queries
(
&
db
,
&
mut
w
,
blockstamp
.id
,
tx_dbs_queries
)
?
;
exec_currency_queries
(
&
db
,
&
mut
w
,
blockstamp
.id
,
tx_dbs_queries
)
?
;
}
else
{
}
CheckAndApplyBlockReturn
::
ForkBlock
|
CheckAndApplyBlockReturn
::
OrphanBlock
=>
{
fatal_error!
(
"apply_rollback(): a block in new branch is not chainable:
\
{{ block_not_chainable: {}, current_blockstamp: {} }}"
,
blockstamp
,
bc
.current_blockstamp
,
);
}
},
Err
(
e
)
=>
{
new_branch_is_valid
=
false
;
new_branch_is_valid
=
false
;
bc
.invalid_forks
.insert
(
*
blockstamp
);
bc
.invalid_forks
.insert
(
*
blockstamp
);
info!
(
"Blockchain: abort rollback: block {} is invalid: {:?}"
,
blockstamp
,
e
);
break
;
break
;
}
}
}
}
else
{
}
else
{
fatal_error!
(
fatal_error!
(
"apply_rollback(): Fail to get block {} on new branch in forks blocks DB !"
,
"apply_rollback(): Fail to get block {} on new branch in forks blocks DB !"
,
...
@@ -162,7 +179,9 @@ pub fn apply_rollback(bc: &mut BlockchainModule, new_bc_branch: Vec<Blockstamp>)
...
@@ -162,7 +179,9 @@ pub fn apply_rollback(bc: &mut BlockchainModule, new_bc_branch: Vec<Blockstamp>)
}
}
}
}
Err
(
DbError
::
WriteAbort
{
..
})
=>
{
Err
(
DbError
::
WriteAbort
{
..
})
=>
{
// reload dbs
// Reset current blockstamp
bc
.current_blockstamp
=
old_current_blockstamp
;
// Reload wot file
let
dbs_path
=
durs_conf
::
get_blockchain_db_path
(
bc
.profile_path
.clone
());
let
dbs_path
=
durs_conf
::
get_blockchain_db_path
(
bc
.profile_path
.clone
());
bc
.wot_databases
=
WotsV10DBs
::
open
(
Some
(
&
dbs_path
));
bc
.wot_databases
=
WotsV10DBs
::
open
(
Some
(
&
dbs_path
));
}
}
...
...
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