Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
parity-bitcoin
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
parity
parity-bitcoin
Commits
f8f8db65
Commit
f8f8db65
authored
5 years ago
by
Svyatoslav Nikolsky
Browse files
Options
Downloads
Patches
Plain Diff
update error reporting in import handler
parent
cd4e99bc
Branches
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pbtc/commands/import.rs
+8
-4
8 additions, 4 deletions
pbtc/commands/import.rs
with
8 additions
and
4 deletions
pbtc/commands/import.rs
+
8
−
4
View file @
f8f8db65
...
...
@@ -7,14 +7,16 @@ pub fn import(cfg: Config, matches: &ArgMatches) -> Result<(), String> {
try
!
(
init_db
(
&
cfg
));
let
blk_path
=
matches
.value_of
(
"PATH"
)
.expect
(
"PATH is required in cli.yml; qed"
);
let
blk_dir
=
::
import
::
open_blk_dir
(
blk_path
)
.map_err
(|
err
|
format!
(
"Failed to open import directory: {}"
,
err
))
?
;
let
mut
writer
=
create_sync_blocks_writer
(
cfg
.db
,
cfg
.consensus
,
cfg
.verification_params
);
let
blk_dir
=
try
!
(::
import
::
open_blk_dir
(
blk_path
)
.map_err
(|
_
|
"Import directory does not exist"
.to_owned
()));
let
mut
counter
=
0
;
let
mut
previous_hash
=
None
;
for
blk
in
blk_dir
{
// TODO: verify magic!
let
blk
=
try
!
(
blk
.map_err
(|
_
|
"Cannot read block"
.to_owned
()));
let
blk
=
blk
.map_err
(|
err
|
format!
(
"Cannot read block: {:?}. Previous block: {:?}"
,
err
,
previous_hash
))
?
;
let
blk_hash
=
blk
.block
.hash
()
.reversed
();
match
writer
.append_block
(
blk
.block
)
{
Ok
(
_
)
=>
{
counter
+=
1
;
...
...
@@ -23,8 +25,10 @@ pub fn import(cfg: Config, matches: &ArgMatches) -> Result<(), String> {
}
}
Err
(
Error
::
TooManyOrphanBlocks
)
=>
return
Err
(
"Too many orphan (unordered) blocks"
.into
()),
Err
(
err
or
)
=>
return
Err
(
format!
(
"Cannot append block: {:?}
"
,
error
)),
Err
(
err
)
=>
return
Err
(
format!
(
"Cannot append block: {:?}
. Block: {}"
,
err
,
blk_hash
)),
}
previous_hash
=
Some
(
blk_hash
);
}
info!
(
"Finished import of {} blocks"
,
counter
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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