From 5ebe2243d8e9dfad867d7cb60d851c7c6d1f31ee Mon Sep 17 00:00:00 2001 From: Ian Norden Date: Thu, 16 May 2019 23:15:54 -0500 Subject: [PATCH] goimports -w --- cmd/contractWatcher.go | 2 + .../contract_watcher_full_transformer_test.go | 2 + integration_test/sync_and_publish.go | 69 +++++++++++++++++++ libraries/shared/watcher/event_watcher.go | 2 +- pkg/config/contract.go | 3 +- pkg/config/plugin_test.go | 5 +- .../full/retriever/retriever_suite_test.go | 2 + .../transformer/transformer_suite_test.go | 2 + .../repository/repository_suite_test.go | 2 + .../header/retriever/retriever_suite_test.go | 2 + .../transformer/transformer_suite_test.go | 2 + .../repository/repository_suite_test.go | 2 + .../shared/retriever/address_retriever.go | 2 + .../shared/retriever/retriever_suite_test.go | 2 + pkg/core/blockchain.go | 3 +- pkg/datastore/ethereum/database.go | 1 + pkg/datastore/postgres/postgres_suite_test.go | 3 +- .../repositories/block_repository_test.go | 5 +- .../full_sync_log_repository_test.go | 3 +- .../full_sync_receipt_repository.go | 1 + .../repositories/repositories_suite_test.go | 3 +- pkg/eth/client/eth_client.go | 3 +- pkg/eth/cold_import/node_builder.go | 3 +- pkg/eth/cold_import/node_builder_test.go | 1 + .../cold_db/transaction_converter.go | 3 +- .../common/receipt_converter_test.go | 1 + .../converters/rpc/transaction_converter.go | 3 +- pkg/eth/node/node.go | 2 + pkg/fakes/mock_blockchain.go | 3 +- pkg/history/history_suite_test.go | 3 +- pkg/history/populate_blocks_test.go | 3 +- pkg/history/validation_window.go | 1 + pkg/history/validation_window_test.go | 3 +- pkg/ipfs/processor.go | 1 - pkg/ipfs/retreiver.go | 17 +++++ pkg/plugin/generator.go | 1 + pkg/plugin/manager/manager.go | 10 +-- .../mocks/repository.go => rpc/client.go} | 22 +++--- pkg/rpc/server.go | 31 +++++++++ pkg/rpc/subscription.go | 59 ++++++++++++++++ utils/utils.go | 5 +- .../ethereum/go-ethereum/statediff/api.go | 4 -- 42 files changed, 257 insertions(+), 40 deletions(-) create mode 100644 integration_test/sync_and_publish.go create mode 100644 pkg/ipfs/retreiver.go rename pkg/{ipfs/test_helpers/mocks/repository.go => rpc/client.go} (64%) create mode 100644 pkg/rpc/server.go create mode 100644 pkg/rpc/subscription.go diff --git a/cmd/contractWatcher.go b/cmd/contractWatcher.go index 11238869..8dcd0aac 100644 --- a/cmd/contractWatcher.go +++ b/cmd/contractWatcher.go @@ -20,6 +20,8 @@ import ( "fmt" "time" + "github.com/vulcanize/vulcanizedb/pkg/config" + log "github.com/sirupsen/logrus" "github.com/spf13/cobra" diff --git a/integration_test/contract_watcher_full_transformer_test.go b/integration_test/contract_watcher_full_transformer_test.go index 0a606c43..f6623650 100644 --- a/integration_test/contract_watcher_full_transformer_test.go +++ b/integration_test/contract_watcher_full_transformer_test.go @@ -22,6 +22,8 @@ import ( "strings" "time" + "github.com/vulcanize/vulcanizedb/pkg/config" + "github.com/ethereum/go-ethereum/common" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/integration_test/sync_and_publish.go b/integration_test/sync_and_publish.go new file mode 100644 index 00000000..a83c8c7a --- /dev/null +++ b/integration_test/sync_and_publish.go @@ -0,0 +1,69 @@ +package integration + +/* WIP +import ( + "github.com/ethereum/go-ethereum/rpc" + "github.com/ethereum/go-ethereum/ethclient" + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + + "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/helpers/test_helpers" + "github.com/vulcanize/vulcanizedb/pkg/core" + "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" + "github.com/vulcanize/vulcanizedb/pkg/ipfs" + "github.com/vulcanize/vulcanizedb/test_config" + "github.com/vulcanize/vulcanizedb/pkg/config" + "github.com/vulcanize/vulcanizedb/pkg/geth" + "github.com/vulcanize/vulcanizedb/pkg/geth/client" + rpc2 "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc" + "github.com/vulcanize/vulcanizedb/pkg/geth/node" +) + +var _ = Describe("IPFS Processor", func() { + var processor ipfs.SyncAndPublish + var err error + var db *postgres.DB + var bc core.BlockChain + var ec core.EthClient + var rc core.RpcClient + var quitChan chan bool + + AfterEach(func() { + test_helpers.TearDown(db) + }) + + BeforeEach(func() { + db, bc, ec, rc = setup() + quitChan = make(chan bool) + processor, err = ipfs.NewIPFSProcessor("~/.ipfs", db, ec, rc, quitChan) + }) + + Describe("Process", func() { + It("Polls specified contract methods using contract's argument list", func() { + + }) + }) +}) + +func setup() (*postgres.DB, core.BlockChain, core.EthClient, core.RpcClient) { + con := test_config.InfuraClient + infuraIPC := con.IPCPath + rawRpcClient, err := rpc.Dial(infuraIPC) + Expect(err).NotTo(HaveOccurred()) + rpcClient := client.NewRpcClient(rawRpcClient, infuraIPC) + ethClient := ethclient.NewClient(rawRpcClient) + blockChainClient := client.NewEthClient(ethClient) + node := node.MakeNode(rpcClient) + transactionConverter := rpc2.NewRpcTransactionConverter(ethClient) + blockChain := geth.NewBlockChain(blockChainClient, rpcClient, node, transactionConverter) + + db, err := postgres.NewDB(config.Database{ + Hostname: "localhost", + Name: "vulcanize_private", + Port: 5432, + }, blockChain.Node()) + Expect(err).NotTo(HaveOccurred()) + + return db, blockChain, ethClient, rpcClient +} +*/ diff --git a/libraries/shared/watcher/event_watcher.go b/libraries/shared/watcher/event_watcher.go index 7ab70897..e6b43c1b 100644 --- a/libraries/shared/watcher/event_watcher.go +++ b/libraries/shared/watcher/event_watcher.go @@ -125,4 +125,4 @@ func (watcher *EventWatcher) delegateLogs(errs chan error) { } else { watcher.delegateLogs(errs) } -} +} \ No newline at end of file diff --git a/pkg/config/contract.go b/pkg/config/contract.go index fe415cd7..77f71678 100644 --- a/pkg/config/contract.go +++ b/pkg/config/contract.go @@ -17,10 +17,11 @@ package config import ( + "strings" + log "github.com/sirupsen/logrus" "github.com/spf13/viper" "github.com/vulcanize/vulcanizedb/pkg/eth" - "strings" ) // Config struct for generic contract transformer diff --git a/pkg/config/plugin_test.go b/pkg/config/plugin_test.go index 1d1616bb..7eeed236 100644 --- a/pkg/config/plugin_test.go +++ b/pkg/config/plugin_test.go @@ -17,11 +17,12 @@ package config_test import ( + "os" + "path/filepath" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/config" - "os" - "path/filepath" ) var allDifferentPathsConfig = config.Plugin{ diff --git a/pkg/contract_watcher/full/retriever/retriever_suite_test.go b/pkg/contract_watcher/full/retriever/retriever_suite_test.go index 2f97ce0a..a79487c7 100644 --- a/pkg/contract_watcher/full/retriever/retriever_suite_test.go +++ b/pkg/contract_watcher/full/retriever/retriever_suite_test.go @@ -20,6 +20,8 @@ import ( "io/ioutil" "testing" + "github.com/sirupsen/logrus" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sirupsen/logrus" diff --git a/pkg/contract_watcher/full/transformer/transformer_suite_test.go b/pkg/contract_watcher/full/transformer/transformer_suite_test.go index aac31e85..ed6bb349 100644 --- a/pkg/contract_watcher/full/transformer/transformer_suite_test.go +++ b/pkg/contract_watcher/full/transformer/transformer_suite_test.go @@ -20,6 +20,8 @@ import ( "io/ioutil" "testing" + "github.com/sirupsen/logrus" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sirupsen/logrus" diff --git a/pkg/contract_watcher/header/repository/repository_suite_test.go b/pkg/contract_watcher/header/repository/repository_suite_test.go index 87726ebd..a80fea54 100644 --- a/pkg/contract_watcher/header/repository/repository_suite_test.go +++ b/pkg/contract_watcher/header/repository/repository_suite_test.go @@ -20,6 +20,8 @@ import ( "io/ioutil" "testing" + "github.com/sirupsen/logrus" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sirupsen/logrus" diff --git a/pkg/contract_watcher/header/retriever/retriever_suite_test.go b/pkg/contract_watcher/header/retriever/retriever_suite_test.go index f6d4967e..ef2a009a 100644 --- a/pkg/contract_watcher/header/retriever/retriever_suite_test.go +++ b/pkg/contract_watcher/header/retriever/retriever_suite_test.go @@ -20,6 +20,8 @@ import ( "io/ioutil" "testing" + "github.com/sirupsen/logrus" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sirupsen/logrus" diff --git a/pkg/contract_watcher/header/transformer/transformer_suite_test.go b/pkg/contract_watcher/header/transformer/transformer_suite_test.go index 56bcc01c..91ee7975 100644 --- a/pkg/contract_watcher/header/transformer/transformer_suite_test.go +++ b/pkg/contract_watcher/header/transformer/transformer_suite_test.go @@ -20,6 +20,8 @@ import ( "io/ioutil" "testing" + "github.com/sirupsen/logrus" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sirupsen/logrus" diff --git a/pkg/contract_watcher/shared/repository/repository_suite_test.go b/pkg/contract_watcher/shared/repository/repository_suite_test.go index 707e1917..f10c9448 100644 --- a/pkg/contract_watcher/shared/repository/repository_suite_test.go +++ b/pkg/contract_watcher/shared/repository/repository_suite_test.go @@ -20,6 +20,8 @@ import ( "io/ioutil" "testing" + "github.com/sirupsen/logrus" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sirupsen/logrus" diff --git a/pkg/contract_watcher/shared/retriever/address_retriever.go b/pkg/contract_watcher/shared/retriever/address_retriever.go index 8afb2b98..074537b3 100644 --- a/pkg/contract_watcher/shared/retriever/address_retriever.go +++ b/pkg/contract_watcher/shared/retriever/address_retriever.go @@ -20,6 +20,8 @@ import ( "fmt" "strings" + "github.com/vulcanize/vulcanizedb/pkg/contract_watcher/shared/types" + "github.com/ethereum/go-ethereum/accounts/abi" "github.com/ethereum/go-ethereum/common" diff --git a/pkg/contract_watcher/shared/retriever/retriever_suite_test.go b/pkg/contract_watcher/shared/retriever/retriever_suite_test.go index 6056bbfc..93c4ff6a 100644 --- a/pkg/contract_watcher/shared/retriever/retriever_suite_test.go +++ b/pkg/contract_watcher/shared/retriever/retriever_suite_test.go @@ -20,6 +20,8 @@ import ( "io/ioutil" "testing" + "github.com/sirupsen/logrus" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/sirupsen/logrus" diff --git a/pkg/core/blockchain.go b/pkg/core/blockchain.go index 7f87a5b0..b657c34f 100644 --- a/pkg/core/blockchain.go +++ b/pkg/core/blockchain.go @@ -17,9 +17,10 @@ package core import ( - "github.com/ethereum/go-ethereum/common" "math/big" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/core/types" ) diff --git a/pkg/datastore/ethereum/database.go b/pkg/datastore/ethereum/database.go index 2f36ea2a..6084975c 100644 --- a/pkg/datastore/ethereum/database.go +++ b/pkg/datastore/ethereum/database.go @@ -18,6 +18,7 @@ package ethereum import ( "fmt" + "github.com/ethereum/go-ethereum/core/rawdb" "github.com/sirupsen/logrus" diff --git a/pkg/datastore/postgres/postgres_suite_test.go b/pkg/datastore/postgres/postgres_suite_test.go index 0868f58c..e85bb75c 100644 --- a/pkg/datastore/postgres/postgres_suite_test.go +++ b/pkg/datastore/postgres/postgres_suite_test.go @@ -19,9 +19,10 @@ package postgres_test import ( "testing" - log "github.com/sirupsen/logrus" "io/ioutil" + log "github.com/sirupsen/logrus" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/pkg/datastore/postgres/repositories/block_repository_test.go b/pkg/datastore/postgres/repositories/block_repository_test.go index c0542066..a9ba0344 100644 --- a/pkg/datastore/postgres/repositories/block_repository_test.go +++ b/pkg/datastore/postgres/repositories/block_repository_test.go @@ -18,11 +18,12 @@ package repositories_test import ( "bytes" + "math/big" + "strconv" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/vulcanize/vulcanizedb/pkg/fakes" - "math/big" - "strconv" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/pkg/datastore/postgres/repositories/full_sync_log_repository_test.go b/pkg/datastore/postgres/repositories/full_sync_log_repository_test.go index 508b442a..15999607 100644 --- a/pkg/datastore/postgres/repositories/full_sync_log_repository_test.go +++ b/pkg/datastore/postgres/repositories/full_sync_log_repository_test.go @@ -17,9 +17,10 @@ package repositories_test import ( - "github.com/vulcanize/vulcanizedb/pkg/fakes" "sort" + "github.com/vulcanize/vulcanizedb/pkg/fakes" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/core" diff --git a/pkg/datastore/postgres/repositories/full_sync_receipt_repository.go b/pkg/datastore/postgres/repositories/full_sync_receipt_repository.go index c47b3baf..015ee2f6 100644 --- a/pkg/datastore/postgres/repositories/full_sync_receipt_repository.go +++ b/pkg/datastore/postgres/repositories/full_sync_receipt_repository.go @@ -18,6 +18,7 @@ package repositories import ( "database/sql" + "github.com/jmoiron/sqlx" "github.com/sirupsen/logrus" "github.com/vulcanize/vulcanizedb/libraries/shared/repository" diff --git a/pkg/datastore/postgres/repositories/repositories_suite_test.go b/pkg/datastore/postgres/repositories/repositories_suite_test.go index c34a23b0..3f9cf68b 100644 --- a/pkg/datastore/postgres/repositories/repositories_suite_test.go +++ b/pkg/datastore/postgres/repositories/repositories_suite_test.go @@ -17,10 +17,11 @@ package repositories_test import ( - "github.com/sirupsen/logrus" "io/ioutil" "testing" + "github.com/sirupsen/logrus" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" ) diff --git a/pkg/eth/client/eth_client.go b/pkg/eth/client/eth_client.go index fca30d39..4e66efa2 100644 --- a/pkg/eth/client/eth_client.go +++ b/pkg/eth/client/eth_client.go @@ -18,11 +18,12 @@ package client import ( "context" + "math/big" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/ethclient" - "math/big" ) type EthClient struct { diff --git a/pkg/eth/cold_import/node_builder.go b/pkg/eth/cold_import/node_builder.go index 9ec55bd6..4c7028fc 100644 --- a/pkg/eth/cold_import/node_builder.go +++ b/pkg/eth/cold_import/node_builder.go @@ -18,11 +18,12 @@ package cold_import import ( "errors" + "strings" + "github.com/ethereum/go-ethereum/common" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/crypto" "github.com/vulcanize/vulcanizedb/pkg/fs" - "strings" ) const ( diff --git a/pkg/eth/cold_import/node_builder_test.go b/pkg/eth/cold_import/node_builder_test.go index 3e4db277..8c3730c5 100644 --- a/pkg/eth/cold_import/node_builder_test.go +++ b/pkg/eth/cold_import/node_builder_test.go @@ -18,6 +18,7 @@ package cold_import_test import ( "errors" + "github.com/ethereum/go-ethereum/common" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" diff --git a/pkg/eth/converters/cold_db/transaction_converter.go b/pkg/eth/converters/cold_db/transaction_converter.go index ebf5e877..fcf0b17f 100644 --- a/pkg/eth/converters/cold_db/transaction_converter.go +++ b/pkg/eth/converters/cold_db/transaction_converter.go @@ -17,11 +17,12 @@ package cold_db import ( + "strings" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/vulcanize/vulcanizedb/pkg/core" "golang.org/x/sync/errgroup" - "strings" ) type ColdDbTransactionConverter struct{} diff --git a/pkg/eth/converters/common/receipt_converter_test.go b/pkg/eth/converters/common/receipt_converter_test.go index a861b770..c0bd33f5 100644 --- a/pkg/eth/converters/common/receipt_converter_test.go +++ b/pkg/eth/converters/common/receipt_converter_test.go @@ -18,6 +18,7 @@ package common_test import ( "bytes" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/core/types" diff --git a/pkg/eth/converters/rpc/transaction_converter.go b/pkg/eth/converters/rpc/transaction_converter.go index acbb17cb..906536d5 100644 --- a/pkg/eth/converters/rpc/transaction_converter.go +++ b/pkg/eth/converters/rpc/transaction_converter.go @@ -20,11 +20,12 @@ import ( "bytes" "context" "fmt" - "github.com/ethereum/go-ethereum/common/hexutil" "log" "math/big" "strings" + "github.com/ethereum/go-ethereum/common/hexutil" + "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/rlp" diff --git a/pkg/eth/node/node.go b/pkg/eth/node/node.go index a60d271e..39b72aaf 100644 --- a/pkg/eth/node/node.go +++ b/pkg/eth/node/node.go @@ -22,6 +22,8 @@ import ( "strconv" "strings" + "strings" + "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/p2p" log "github.com/sirupsen/logrus" diff --git a/pkg/fakes/mock_blockchain.go b/pkg/fakes/mock_blockchain.go index c0f89b8a..7c360cc7 100644 --- a/pkg/fakes/mock_blockchain.go +++ b/pkg/fakes/mock_blockchain.go @@ -17,9 +17,10 @@ package fakes import ( - "github.com/ethereum/go-ethereum/common" "math/big" + "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum" "github.com/ethereum/go-ethereum/core/types" . "github.com/onsi/gomega" diff --git a/pkg/history/history_suite_test.go b/pkg/history/history_suite_test.go index 99cd6951..e1bd3f55 100644 --- a/pkg/history/history_suite_test.go +++ b/pkg/history/history_suite_test.go @@ -20,9 +20,10 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - log "github.com/sirupsen/logrus" "io/ioutil" "testing" + + log "github.com/sirupsen/logrus" ) func init() { diff --git a/pkg/history/populate_blocks_test.go b/pkg/history/populate_blocks_test.go index 6a5138ed..5629d52e 100644 --- a/pkg/history/populate_blocks_test.go +++ b/pkg/history/populate_blocks_test.go @@ -17,11 +17,12 @@ package history_test import ( + "math/big" + . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" "github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/history" - "math/big" ) var _ = Describe("Populating blocks", func() { diff --git a/pkg/history/validation_window.go b/pkg/history/validation_window.go index 92e360ad..79ba2a00 100644 --- a/pkg/history/validation_window.go +++ b/pkg/history/validation_window.go @@ -18,6 +18,7 @@ package history import ( "fmt" + log "github.com/sirupsen/logrus" "github.com/vulcanize/vulcanizedb/pkg/core" ) diff --git a/pkg/history/validation_window_test.go b/pkg/history/validation_window_test.go index 86e45c66..d12427bd 100644 --- a/pkg/history/validation_window_test.go +++ b/pkg/history/validation_window_test.go @@ -20,9 +20,10 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "math/big" + "github.com/vulcanize/vulcanizedb/pkg/fakes" "github.com/vulcanize/vulcanizedb/pkg/history" - "math/big" ) var _ = Describe("Validation window", func() { diff --git a/pkg/ipfs/processor.go b/pkg/ipfs/processor.go index 451784cf..9678d73c 100644 --- a/pkg/ipfs/processor.go +++ b/pkg/ipfs/processor.go @@ -98,7 +98,6 @@ func (i *Processor) Process(wg *sync.WaitGroup) error { case err = <-sub.Err(): log.Error(err) case <-i.QuitChan: - println("quiting") log.Info("quiting IPFSProcessor") wg.Done() return diff --git a/pkg/ipfs/retreiver.go b/pkg/ipfs/retreiver.go new file mode 100644 index 00000000..63fc346e --- /dev/null +++ b/pkg/ipfs/retreiver.go @@ -0,0 +1,17 @@ +// VulcanizeDB +// Copyright © 2019 Vulcanize + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package ipfs diff --git a/pkg/plugin/generator.go b/pkg/plugin/generator.go index d0038ee7..193ba7bc 100644 --- a/pkg/plugin/generator.go +++ b/pkg/plugin/generator.go @@ -18,6 +18,7 @@ package plugin import ( "errors" + "github.com/vulcanize/vulcanizedb/pkg/config" "github.com/vulcanize/vulcanizedb/pkg/plugin/builder" "github.com/vulcanize/vulcanizedb/pkg/plugin/manager" diff --git a/pkg/plugin/manager/manager.go b/pkg/plugin/manager/manager.go index a1a0abe8..4db86477 100644 --- a/pkg/plugin/manager/manager.go +++ b/pkg/plugin/manager/manager.go @@ -19,13 +19,15 @@ package manager import ( "database/sql" "fmt" - "github.com/lib/pq" - "github.com/pressly/goose" - "github.com/vulcanize/vulcanizedb/pkg/config" - "github.com/vulcanize/vulcanizedb/pkg/plugin/helpers" "io/ioutil" "os" "path/filepath" + + "github.com/lib/pq" + "github.com/pressly/goose" + + "github.com/vulcanize/vulcanizedb/pkg/config" + "github.com/vulcanize/vulcanizedb/pkg/plugin/helpers" ) // Interface for managing the db migrations for plugin transformers diff --git a/pkg/ipfs/test_helpers/mocks/repository.go b/pkg/rpc/client.go similarity index 64% rename from pkg/ipfs/test_helpers/mocks/repository.go rename to pkg/rpc/client.go index dc06ccc9..2ebfa460 100644 --- a/pkg/ipfs/test_helpers/mocks/repository.go +++ b/pkg/rpc/client.go @@ -14,18 +14,18 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -package mocks +package rpc -import "github.com/vulcanize/vulcanizedb/pkg/ipfs" - -// CIDRepository is the underlying struct for the Repository interface -type CIDRepository struct { - PassedCIDPayload *ipfs.CIDPayload - ReturnErr error +type Client interface { } -// Index indexes a cidPayload in Postgres -func (repo *CIDRepository) Index(cidPayload *ipfs.CIDPayload) error { - repo.PassedCIDPayload = cidPayload - return repo.ReturnErr +type RpcClient struct { +} + +func NewRpcClient() *RpcClient { + return &RpcClient{} +} + +func (rpcc *RpcClient) Dial() error { + return nil } diff --git a/pkg/rpc/server.go b/pkg/rpc/server.go new file mode 100644 index 00000000..182d92e1 --- /dev/null +++ b/pkg/rpc/server.go @@ -0,0 +1,31 @@ +// VulcanizeDB +// Copyright © 2019 Vulcanize + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package rpc + +type Server interface { +} + +type RpcServer struct { +} + +func NewRpcServer() *RpcServer { + return &RpcServer{} +} + +func (rpcs *RpcServer) Serve() error { + return nil +} diff --git a/pkg/rpc/subscription.go b/pkg/rpc/subscription.go new file mode 100644 index 00000000..40b4e1d0 --- /dev/null +++ b/pkg/rpc/subscription.go @@ -0,0 +1,59 @@ +// VulcanizeDB +// Copyright © 2019 Vulcanize + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. + +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +package rpc + +// Subscription +type Subscription struct { +} + +// Params are set by the client to tell the server how to filter that is fed into their subscription +type Params struct { + HeaderFilter struct { + Off bool + StartingBlock int64 + EndingBlock int64 // set to 0 or a negative value to have no ending block + Uncles bool + } + TrxFilter struct { + Off bool + StartingBlock int64 + EndingBlock int64 + Src string + Dst string + } + ReceiptFilter struct { + Off bool + StartingBlock int64 + EndingBlock int64 + Topic0s []string + } + StateFilter struct { + Off bool + StartingBlock int64 + EndingBlock int64 + Address string // is converted to state key by taking its keccak256 hash + LeafsOnly bool + } + StorageFilter struct { + Off bool + StartingBlock int64 + EndingBlock int64 + Address string + StorageKey string + LeafsOnly bool + } +} diff --git a/utils/utils.go b/utils/utils.go index ce624616..768205e2 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -17,12 +17,13 @@ package utils import ( - "github.com/jmoiron/sqlx" - "github.com/sirupsen/logrus" "math/big" "os" "path/filepath" + "github.com/jmoiron/sqlx" + "github.com/sirupsen/logrus" + "github.com/vulcanize/vulcanizedb/pkg/config" "github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres" diff --git a/vendor/github.com/ethereum/go-ethereum/statediff/api.go b/vendor/github.com/ethereum/go-ethereum/statediff/api.go index db9573d4..498c2f75 100644 --- a/vendor/github.com/ethereum/go-ethereum/statediff/api.go +++ b/vendor/github.com/ethereum/go-ethereum/statediff/api.go @@ -18,7 +18,6 @@ package statediff import ( "context" - "sync" "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rpc" @@ -35,15 +34,12 @@ const APIVersion = "0.0.1" // are produced by a full node type PublicStateDiffAPI struct { sds IService - - mu sync.Mutex } // NewPublicStateDiffAPI create a new state diff websocket streaming service. func NewPublicStateDiffAPI(sds IService) *PublicStateDiffAPI { return &PublicStateDiffAPI{ sds: sds, - mu: sync.Mutex{}, } }