From 84b42147c49c9eb6ed330457340d04818be78452 Mon Sep 17 00:00:00 2001 From: Yahtoo Ma Date: Thu, 11 Jul 2019 09:03:43 +0800 Subject: [PATCH] Fix review bug --- netsync/chainmgr/block_keeper.go | 6 +++++- netsync/chainmgr/block_process.go | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/netsync/chainmgr/block_keeper.go b/netsync/chainmgr/block_keeper.go index 2ebc88f8..43f8521e 100644 --- a/netsync/chainmgr/block_keeper.go +++ b/netsync/chainmgr/block_keeper.go @@ -119,7 +119,11 @@ func (bk *blockKeeper) locateHeaders(locator []*bc.Hash, stopHash *bc.Hash, skip } headers = append(headers, startHeader) - for num, index := uint64(0), startHeader.Height; num < maxNum-1 && index < stopHeader.Height; num++ { + if stopHeader.Height == startHeader.Height { + return headers, nil + } + + for num, index := uint64(0), startHeader.Height; num < maxNum-1; num++ { index += skip + 1 if index >= stopHeader.Height { headers = append(headers, stopHeader) diff --git a/netsync/chainmgr/block_process.go b/netsync/chainmgr/block_process.go index c40343ab..4caf9f75 100644 --- a/netsync/chainmgr/block_process.go +++ b/netsync/chainmgr/block_process.go @@ -57,8 +57,7 @@ func (bp *blockProcessor) process(downloadNotifyCh chan struct{}, ProcessStop ch bp.storage.deleteBlock(nextHeight) } - _, ok := <-downloadNotifyCh - if !ok { + if _, ok := <-downloadNotifyCh; !ok { return } } -- 2.11.0