From 68cda2fe79eeff1c928957a69d910ff73c3d9a61 Mon Sep 17 00:00:00 2001 From: Robert Habermeier Date: Fri, 20 Sep 2019 18:44:19 +0200 Subject: [PATCH] find best_containing even if best chain is shorter (#3657) --- substrate/core/client/src/client.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/substrate/core/client/src/client.rs b/substrate/core/client/src/client.rs index f418b79127..acba5fa824 100644 --- a/substrate/core/client/src/client.rs +++ b/substrate/core/client/src/client.rs @@ -1704,10 +1704,10 @@ where let info = self.backend.blockchain().info(); - let canon_hash = self.backend.blockchain().hash(*target_header.number())? - .ok_or_else(|| error::Error::from(format!("failed to get hash for block number {}", target_header.number())))?; + // this can be `None` if the best chain is shorter than the target header. + let maybe_canon_hash = self.backend.blockchain().hash(*target_header.number())?; - if canon_hash == target_hash { + if maybe_canon_hash.as_ref() == Some(&target_hash) { // if a `max_number` is given we try to fetch the block at the // given depth, if it doesn't exist or `max_number` is not // provided, we continue to search from all leaves below.