From 074140b9acf7f4dc443975b673ef02329a711f8a Mon Sep 17 00:00:00 2001 From: Taka Goto Date: Tue, 15 Jan 2019 16:34:20 -0600 Subject: [PATCH] iterate for loop by headers instead of blocknumbers --- pkg/geth/blockchain.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/geth/blockchain.go b/pkg/geth/blockchain.go index afe3df81..77872f06 100644 --- a/pkg/geth/blockchain.go +++ b/pkg/geth/blockchain.go @@ -94,8 +94,8 @@ func (blockChain *BlockChain) getPOWHeaders(blockNumbers []int64) (headers []cor return headers, err } - for index, _ := range blockNumbers { - header, _ := blockChain.headerConverter.Convert(&POWHeaders[index], POWHeaders[index].Hash().String()) + for _, POWHeader := range POWHeaders { + header, _ := blockChain.headerConverter.Convert(&POWHeader, POWHeader.Hash().String()) headers = append(headers, header) } @@ -159,9 +159,8 @@ func (blockChain *BlockChain) getPOAHeaders(blockNumbers []int64) (headers []cor return headers, err } - for index, _ := range blockNumbers { + for _, POAHeader := range POAHeaders { var header core.Header - var POAHeader = POAHeaders[index] //Header.Number of the newest block will return nil. if _, err := strconv.ParseUint(POAHeader.Number.ToInt().String(), 16, 64); err == nil { header, _ = blockChain.headerConverter.Convert(&types.Header{