From 778d404d3c040b8e7763579f755b8df2768685bc Mon Sep 17 00:00:00 2001 From: SW van Heerden Date: Fri, 5 Jun 2020 11:03:44 +0200 Subject: [PATCH] fix forward sync explicit index ref --- .../core/src/base_node/states/forward_block_sync.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/base_layer/core/src/base_node/states/forward_block_sync.rs b/base_layer/core/src/base_node/states/forward_block_sync.rs index 36452aac2b..208dc0486b 100644 --- a/base_layer/core/src/base_node/states/forward_block_sync.rs +++ b/base_layer/core/src/base_node/states/forward_block_sync.rs @@ -237,12 +237,13 @@ async fn download_blocks( match shared.comms.fetch_blocks_with_hashes(curr_headers.clone()).await { Ok(blocks) => { info!(target: LOG_TARGET, "Received {} blocks from peer", blocks.len()); - - if let StatusInfo::BlockSync(ref mut info) = shared.info { - info.tip_height = Some(blocks[blocks.len() - 1].block().header.height); - info.local_height = Some(blocks[0].block().header.height); + if !blocks.is_empty() { + if let StatusInfo::BlockSync(ref mut info) = shared.info { + info.tip_height = Some(blocks[blocks.len() - 1].block().header.height); + info.local_height = Some(blocks[0].block().header.height); + } + shared.publish_event_info().await; } - shared.publish_event_info().await; for i in 0..blocks.len() { let hist_block = &blocks[i]; let header = &curr_headers[i];