From 9cdf41f5f486a368d2016293f3816908019c7f18 Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 14 Jan 2021 14:06:30 +1000 Subject: [PATCH] Panic if the lookahead limit is misconfigured (#1589) --- zebrad/src/components/sync.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/zebrad/src/components/sync.rs b/zebrad/src/components/sync.rs index f44daf13..ff36bc6c 100644 --- a/zebrad/src/components/sync.rs +++ b/zebrad/src/components/sync.rs @@ -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,