From 8b31d12716b08f305f9541d8de80b4296b726a3e Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Thu, 29 Aug 2019 14:57:58 -0500 Subject: [PATCH] fixes after rebase --- cmd/syncAndPublish.go | 6 +++++- cmd/syncPublishScreenAndServe.go | 6 +++++- ...ble.sql => 00029_create_header_cids_table.sql} | 0 ...ql => 00030_create_transaction_cids_table.sql} | 0 ...le.sql => 00031_create_receipt_cids_table.sql} | 0 ...able.sql => 00032_create_state_cids_table.sql} | 0 ...le.sql => 00033_create_storage_cids_table.sql} | 0 ...ble.sql => 00034_create_ipfs_blocks_table.sql} | 0 pkg/eth/converters/common/block_converter_test.go | 2 +- pkg/ipfs/mocks/test_data.go | 2 +- pkg/ipfs/publisher.go | 2 +- pkg/ipfs/publisher_test.go | 15 ++++++++++++++- pkg/ipfs/types.go | 2 +- pkg/seed_node/repository.go | 2 +- 14 files changed, 29 insertions(+), 8 deletions(-) rename db/migrations/{00028_create_header_cids_table.sql => 00029_create_header_cids_table.sql} (100%) rename db/migrations/{00029_create_transaction_cids_table.sql => 00030_create_transaction_cids_table.sql} (100%) rename db/migrations/{00030_create_receipt_cids_table.sql => 00031_create_receipt_cids_table.sql} (100%) rename db/migrations/{00031_create_state_cids_table.sql => 00032_create_state_cids_table.sql} (100%) rename db/migrations/{00032_create_storage_cids_table.sql => 00033_create_storage_cids_table.sql} (100%) rename db/migrations/{00033_create_ipfs_blocks_table.sql => 00034_create_ipfs_blocks_table.sql} (100%) diff --git a/cmd/syncAndPublish.go b/cmd/syncAndPublish.go index ff49c393..aef33bd3 100644 --- a/cmd/syncAndPublish.go +++ b/cmd/syncAndPublish.go @@ -69,7 +69,11 @@ func syncAndPublish() { } ipfsPath = filepath.Join(home, ".ipfs") } - processor, err := seed_node.NewSeedNode(ipfsPath, &db, rpcClient, quitChan, 1) + workers := viper.GetInt("client.workers") + if workers < 1 { + workers = 1 + } + processor, err := seed_node.NewSeedNode(ipfsPath, &db, rpcClient, quitChan, workers) if err != nil { log.Fatal(err) } diff --git a/cmd/syncPublishScreenAndServe.go b/cmd/syncPublishScreenAndServe.go index d8dea81f..8e52647c 100644 --- a/cmd/syncPublishScreenAndServe.go +++ b/cmd/syncPublishScreenAndServe.go @@ -63,7 +63,11 @@ func syncPublishScreenAndServe() { } ipfsPath = filepath.Join(home, ".ipfs") } - processor, err := seed_node.NewSeedNode(ipfsPath, &db, rpcClient, quitChan, 1) + workers := viper.GetInt("client.workers") + if workers < 1 { + workers = 1 + } + processor, err := seed_node.NewSeedNode(ipfsPath, &db, rpcClient, quitChan, workers) if err != nil { log.Fatal(err) } diff --git a/db/migrations/00028_create_header_cids_table.sql b/db/migrations/00029_create_header_cids_table.sql similarity index 100% rename from db/migrations/00028_create_header_cids_table.sql rename to db/migrations/00029_create_header_cids_table.sql diff --git a/db/migrations/00029_create_transaction_cids_table.sql b/db/migrations/00030_create_transaction_cids_table.sql similarity index 100% rename from db/migrations/00029_create_transaction_cids_table.sql rename to db/migrations/00030_create_transaction_cids_table.sql diff --git a/db/migrations/00030_create_receipt_cids_table.sql b/db/migrations/00031_create_receipt_cids_table.sql similarity index 100% rename from db/migrations/00030_create_receipt_cids_table.sql rename to db/migrations/00031_create_receipt_cids_table.sql diff --git a/db/migrations/00031_create_state_cids_table.sql b/db/migrations/00032_create_state_cids_table.sql similarity index 100% rename from db/migrations/00031_create_state_cids_table.sql rename to db/migrations/00032_create_state_cids_table.sql diff --git a/db/migrations/00032_create_storage_cids_table.sql b/db/migrations/00033_create_storage_cids_table.sql similarity index 100% rename from db/migrations/00032_create_storage_cids_table.sql rename to db/migrations/00033_create_storage_cids_table.sql diff --git a/db/migrations/00033_create_ipfs_blocks_table.sql b/db/migrations/00034_create_ipfs_blocks_table.sql similarity index 100% rename from db/migrations/00033_create_ipfs_blocks_table.sql rename to db/migrations/00034_create_ipfs_blocks_table.sql diff --git a/pkg/eth/converters/common/block_converter_test.go b/pkg/eth/converters/common/block_converter_test.go index 1d798a81..f7466d64 100644 --- a/pkg/eth/converters/common/block_converter_test.go +++ b/pkg/eth/converters/common/block_converter_test.go @@ -76,7 +76,7 @@ var _ = Describe("Conversion of GethBlock to core.Block", func() { Expect(coreBlock.ParentHash).To(Equal(block.ParentHash().Hex())) Expect(coreBlock.ExtraData).To(Equal(hexutil.Encode(block.Extra()))) Expect(coreBlock.Size).To(Equal(block.Size().String())) - Expect(coreBlock.Time).To(Equal(int64(time))) + Expect(coreBlock.Time).To(Equal(time)) Expect(coreBlock.UncleHash).To(Equal(block.UncleHash().Hex())) Expect(coreBlock.IsFinal).To(BeFalse()) }) diff --git a/pkg/ipfs/mocks/test_data.go b/pkg/ipfs/mocks/test_data.go index e95e9a5e..fe2936d0 100644 --- a/pkg/ipfs/mocks/test_data.go +++ b/pkg/ipfs/mocks/test_data.go @@ -208,7 +208,7 @@ var ( BlockNumber: "1", BlockHash: MockBlock.Hash(), HeaderCID: "mockHeaderCID", - UncleCIDS: make(map[common.Hash]string), + UncleCIDs: make(map[common.Hash]string), TransactionCIDs: map[common.Hash]*ipfs.TrxMetaData{ MockTransactions[0].Hash(): { CID: "mockTrxCID1", diff --git a/pkg/ipfs/publisher.go b/pkg/ipfs/publisher.go index 14a0bf97..b5db48a5 100644 --- a/pkg/ipfs/publisher.go +++ b/pkg/ipfs/publisher.go @@ -125,7 +125,7 @@ func (pub *Publisher) Publish(payload *IPLDPayload) (*CIDPayload, error) { BlockHash: payload.BlockHash, BlockNumber: payload.BlockNumber.String(), HeaderCID: headerCid, - UncleCIDS: uncleCids, + UncleCIDs: uncleCids, TransactionCIDs: transactionCids, ReceiptCIDs: receiptsCids, StateNodeCIDs: stateNodeCids, diff --git a/pkg/ipfs/publisher_test.go b/pkg/ipfs/publisher_test.go index caad0e4d..7d45d807 100644 --- a/pkg/ipfs/publisher_test.go +++ b/pkg/ipfs/publisher_test.go @@ -57,7 +57,20 @@ var _ = Describe("Publisher", func() { } cidPayload, err := publisher.Publish(mocks.MockIPLDPayload) Expect(err).ToNot(HaveOccurred()) - Expect(*cidPayload).To(Equal(*mocks.MockCIDPayload)) + Expect(cidPayload.BlockNumber).To(Equal(mocks.MockCIDPayload.BlockNumber)) + Expect(cidPayload.BlockHash).To(Equal(mocks.MockCIDPayload.BlockHash)) + Expect(cidPayload.UncleCIDs).To(Equal(mocks.MockCIDPayload.UncleCIDs)) + Expect(cidPayload.HeaderCID).To(Equal(mocks.MockCIDPayload.HeaderCID)) + Expect(len(cidPayload.TransactionCIDs)).To(Equal(2)) + Expect(cidPayload.TransactionCIDs[mocks.MockTransactions[0].Hash()]).To(Equal(mocks.MockCIDPayload.TransactionCIDs[mocks.MockTransactions[0].Hash()])) + Expect(cidPayload.TransactionCIDs[mocks.MockTransactions[1].Hash()]).To(Equal(mocks.MockCIDPayload.TransactionCIDs[mocks.MockTransactions[1].Hash()])) + Expect(len(cidPayload.ReceiptCIDs)).To(Equal(2)) + Expect(cidPayload.ReceiptCIDs[mocks.MockTransactions[0].Hash()]).To(Equal(mocks.MockCIDPayload.ReceiptCIDs[mocks.MockTransactions[0].Hash()])) + Expect(cidPayload.ReceiptCIDs[mocks.MockTransactions[1].Hash()]).To(Equal(mocks.MockCIDPayload.ReceiptCIDs[mocks.MockTransactions[1].Hash()])) + Expect(len(cidPayload.StateNodeCIDs)).To(Equal(2)) + Expect(cidPayload.StateNodeCIDs[mocks.ContractLeafKey]).To(Equal(mocks.MockCIDPayload.StateNodeCIDs[mocks.ContractLeafKey])) + Expect(cidPayload.StateNodeCIDs[mocks.AnotherContractLeafKey]).To(Equal(mocks.MockCIDPayload.StateNodeCIDs[mocks.AnotherContractLeafKey])) + Expect(cidPayload.StorageNodeCIDs).To(Equal(mocks.MockCIDPayload.StorageNodeCIDs)) }) }) }) diff --git a/pkg/ipfs/types.go b/pkg/ipfs/types.go index 95b3cb60..5854e78c 100644 --- a/pkg/ipfs/types.go +++ b/pkg/ipfs/types.go @@ -77,7 +77,7 @@ type CIDPayload struct { BlockNumber string BlockHash common.Hash HeaderCID string - UncleCIDS map[common.Hash]string + UncleCIDs map[common.Hash]string TransactionCIDs map[common.Hash]*TrxMetaData ReceiptCIDs map[common.Hash]*ReceiptMetaData StateNodeCIDs map[common.Hash]StateNodeCID diff --git a/pkg/seed_node/repository.go b/pkg/seed_node/repository.go index 8187adb3..f6efacee 100644 --- a/pkg/seed_node/repository.go +++ b/pkg/seed_node/repository.go @@ -56,7 +56,7 @@ func (repo *Repository) Index(cidPayload *ipfs.CIDPayload) error { } return err } - for uncleHash, cid := range cidPayload.UncleCIDS { + for uncleHash, cid := range cidPayload.UncleCIDs { err = repo.indexUncleCID(tx, cid, cidPayload.BlockNumber, uncleHash.Hex()) if err != nil { rollbackErr := tx.Rollback()