Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

ethcore: fix ancient block import error handling #8832

Merged
merged 1 commit into from
Jun 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions ethcore/src/client/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2073,15 +2073,16 @@ impl IoClient for Client {
let first = queued.write().1.pop_front();
if let Some((header, block_bytes, receipts_bytes)) = first {
let hash = header.hash();
client.importer.import_old_block(
let result = client.importer.import_old_block(
Copy link
Collaborator

@niklasad1 niklasad1 Jun 7, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to clarify that I understand this correct, essentially map_or is used the inverse way here right?

Prints a error message when the Result is Ok and don't care when it is Err?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. We could change only .ok() to .err() and it would work, but I thought it was clearer using if let Err.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that is fine!

&header,
&block_bytes,
&receipts_bytes,
&**client.db.read(),
&*client.chain.read()
).ok().map_or((), |e| {
&*client.chain.read(),
);
if let Err(e) = result {
error!(target: "client", "Error importing ancient block: {}", e);
});
}
// remove from pending
queued.write().0.remove(&hash);
} else {
Expand Down