Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let check_txhashset_needed return true on abnormal case #2684

Merged
merged 2 commits into from
Mar 18, 2019
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
12 changes: 9 additions & 3 deletions chain/src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,7 @@ impl Chain {
"{}: header_head not found in chain db: {} at {}",
caller, header_head.last_block_h, header_head.height,
);
return Ok(false);
}

//
Expand All @@ -828,15 +829,20 @@ impl Chain {

if oldest_height < header_head.height.saturating_sub(horizon) {
if oldest_height > 0 {
// this is the normal case. for example:
// body head height is 1 (and not a fork), oldest_height will be 2
// body head height is 0 (a typical fresh node), oldest_height will be 1
// body head height is 10,001 (but at a fork), oldest_height will be 10,001
// body head height is 10,005 (but at a fork with depth 5), oldest_height will be 10,001
debug!(
"{}: need a state sync for txhashset. oldest block which is not on local chain: {} at {}",
caller, oldest_hash, oldest_height,
);
Ok(true)
} else {
error!("{}: something is wrong! oldest_height is 0", caller);
Ok(false)
// this is the abnormal case, when is_on_current_chain() already return Err, and even for genesis block.
error!("{}: corrupted storage? oldest_height is 0 when check_txhashset_needed. state sync is needed", caller);
}
Ok(true)
} else {
Ok(false)
}
Expand Down