Skip to content

Commit

Permalink
Panic if the lookahead limit is misconfigured (#1589)
Browse files Browse the repository at this point in the history
  • Loading branch information
teor2345 authored Jan 14, 2021
1 parent 92d95d4 commit 9cdf41f
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions zebrad/src/components/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,15 @@ where
// We apply a timeout to the verifier to avoid hangs due to missing earlier blocks.
let verifier = Timeout::new(verifier, BLOCK_VERIFY_TIMEOUT);
// Warn the user if we're ignoring their configured lookahead limit
let lookahead_limit = if config.sync.lookahead_limit < MIN_LOOKAHEAD_LIMIT {
tracing::warn!(config_lookahead_limit = ?config.sync.lookahead_limit, ?MIN_LOOKAHEAD_LIMIT,
"configured lookahead limit too low: using minimum lookahead limit");
assert!(
config.sync.lookahead_limit >= MIN_LOOKAHEAD_LIMIT,
"configured lookahead limit {} too low, must be at least {}",
config.sync.lookahead_limit,
MIN_LOOKAHEAD_LIMIT
} else {
config.sync.lookahead_limit
};
);
Self {
genesis_hash: genesis_hash(config.network.network),
lookahead_limit,
lookahead_limit: config.sync.lookahead_limit,
tip_network,
downloads: Box::pin(Downloads::new(block_network, verifier)),
state,
Expand Down

0 comments on commit 9cdf41f

Please sign in to comment.