From dd212c6d5d5c1854f51f3040809750fa933c3c57 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Mon, 2 Dec 2019 13:28:33 +1100 Subject: [PATCH] Tidy beacon chain builder --- beacon_node/beacon_chain/src/builder.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/beacon_node/beacon_chain/src/builder.rs b/beacon_node/beacon_chain/src/builder.rs index c5daafab3e..b1f203fc54 100644 --- a/beacon_node/beacon_chain/src/builder.rs +++ b/beacon_node/beacon_chain/src/builder.rs @@ -326,6 +326,12 @@ where >, String, > { + let log = self + .log + .ok_or_else(|| "Cannot build without a logger".to_string())?; + + // If this beacon chain is being loaded from disk, use the stored head. Otherwise, just use + // the finalized checkpoint (which is probably genesis). let mut canonical_head = if let Some(persisted_beacon_chain) = self.persisted_beacon_chain { persisted_beacon_chain.canonical_head } else { @@ -338,10 +344,6 @@ where .build_all_caches(&self.spec) .map_err(|e| format!("Failed to build state caches: {:?}", e))?; - let log = self - .log - .ok_or_else(|| "Cannot build without a logger".to_string())?; - if canonical_head.beacon_block.state_root != canonical_head.beacon_state_root { return Err("beacon_block.state_root != beacon_state".to_string()); }