From e1a0d894a2fd5fc8ed2dd68b6338febc6d54ad68 Mon Sep 17 00:00:00 2001 From: Elizabeth Engelman Date: Tue, 7 May 2019 17:24:10 -0500 Subject: [PATCH] Update blockchain method GetHeaderByNumbers -> GetHeadersByNumbers --- pkg/core/blockchain.go | 2 +- pkg/fakes/mock_blockchain.go | 2 +- pkg/geth/blockchain.go | 2 +- pkg/geth/blockchain_test.go | 4 ++-- pkg/history/populate_headers.go | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index be2fe9eb..68de3cc1 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -30,7 +30,7 @@ type BlockChain interface { GetBlockByNumber(blockNumber int64) (Block, error) GetEthLogsWithCustomQuery(query ethereum.FilterQuery) ([]types.Log, error) GetHeaderByNumber(blockNumber int64) (Header, error) - GetHeaderByNumbers(blockNumbers []int64) ([]Header, error) + GetHeadersByNumbers(blockNumbers []int64) ([]Header, error) GetLogs(contract Contract, startingBlockNumber *big.Int, endingBlockNumber *big.Int) ([]Log, error) GetTransactions(transactionHashes []common.Hash) ([]TransactionModel, error) LastBlock() (*big.Int, error) diff --git a/pkg/fakes/mock_blockchain.go b/pkg/fakes/mock_blockchain.go index d09a91b3..8ac7f825 100644 --- a/pkg/fakes/mock_blockchain.go +++ b/pkg/fakes/mock_blockchain.go @@ -98,7 +98,7 @@ func (chain *MockBlockChain) GetHeaderByNumber(blockNumber int64) (core.Header, return core.Header{BlockNumber: blockNumber}, nil } -func (chain *MockBlockChain) GetHeaderByNumbers(blockNumbers []int64) ([]core.Header, error) { +func (chain *MockBlockChain) GetHeadersByNumbers(blockNumbers []int64) ([]core.Header, error) { var headers []core.Header for _, blockNumber := range blockNumbers { var header = core.Header{BlockNumber: int64(blockNumber)} diff --git a/pkg/geth/blockchain.go b/pkg/geth/blockchain.go index 5d2c156c..7048487b 100644 --- a/pkg/geth/blockchain.go +++ b/pkg/geth/blockchain.go @@ -79,7 +79,7 @@ func (blockChain *BlockChain) GetHeaderByNumber(blockNumber int64) (header core. return blockChain.getPOWHeader(blockNumber) } -func (blockChain *BlockChain) GetHeaderByNumbers(blockNumbers []int64) (header []core.Header, err error) { +func (blockChain *BlockChain) GetHeadersByNumbers(blockNumbers []int64) (header []core.Header, err error) { if blockChain.node.NetworkID == core.KOVAN_NETWORK_ID { return blockChain.getPOAHeaders(blockNumbers) } diff --git a/pkg/geth/blockchain_test.go b/pkg/geth/blockchain_test.go index d70eda92..e0a8e9c2 100644 --- a/pkg/geth/blockchain_test.go +++ b/pkg/geth/blockchain_test.go @@ -93,7 +93,7 @@ var _ = Describe("Geth blockchain", func() { }) It("fetches headers with multiple blocks", func() { - _, err := blockChain.GetHeaderByNumbers([]int64{100, 99}) + _, err := blockChain.GetHeadersByNumbers([]int64{100, 99}) Expect(err).NotTo(HaveOccurred()) mockRpcClient.AssertBatchCalledWith("eth_getBlockByNumber", 2) @@ -139,7 +139,7 @@ var _ = Describe("Geth blockchain", func() { blockNumber := hexutil.Big(*big.NewInt(100)) mockRpcClient.SetReturnPOAHeaders([]vulcCore.POAHeader{{Number: &blockNumber}}) - _, err := blockChain.GetHeaderByNumbers([]int64{100, 99}) + _, err := blockChain.GetHeadersByNumbers([]int64{100, 99}) Expect(err).NotTo(HaveOccurred()) mockRpcClient.AssertBatchCalledWith("eth_getBlockByNumber", 2) diff --git a/pkg/history/populate_headers.go b/pkg/history/populate_headers.go index e545fd23..c75d4213 100644 --- a/pkg/history/populate_headers.go +++ b/pkg/history/populate_headers.go @@ -48,8 +48,8 @@ func PopulateMissingHeaders(blockchain core.BlockChain, headerRepository datasto return len(blockNumbers), nil } -func RetrieveAndUpdateHeaders(chain core.BlockChain, headerRepository datastore.HeaderRepository, blockNumbers []int64) (int, error) { - headers, err := chain.GetHeaderByNumbers(blockNumbers) +func RetrieveAndUpdateHeaders(blockchain core.BlockChain, headerRepository datastore.HeaderRepository, blockNumbers []int64) (int, error) { + headers, err := blockchain.GetHeadersByNumbers(blockNumbers) for _, header := range headers { _, err = headerRepository.CreateOrUpdateHeader(header) if err != nil {