From 600dd8292108f984a0142853be58c08dd627aebd Mon Sep 17 00:00:00 2001 From: John Barker Date: Thu, 17 Sep 2020 13:14:04 -0700 Subject: [PATCH] Remove ingester, it's not used and no longer on roadmap --- ingester/.gitignore | 1 - ingester/README.md | 26 --- ingester/client/eth.go | 102 ---------- ingester/go.mod | 21 -- ingester/go.sum | 265 -------------------------- ingester/ingester.Dockerfile | 21 -- ingester/logger/logger.go | 211 -------------------- ingester/logger/logger_unix.go | 15 -- ingester/logger/logger_windows.go | 29 --- ingester/logger/prettyconsole.go | 103 ---------- ingester/logger/prettyconsole_test.go | 65 ------- ingester/main.go | 48 ----- ingester/main_test.go | 73 ------- ingester/service/application.go | 150 --------------- ingester/service/config.go | 63 ------ 15 files changed, 1193 deletions(-) delete mode 100644 ingester/.gitignore delete mode 100644 ingester/README.md delete mode 100644 ingester/client/eth.go delete mode 100644 ingester/go.mod delete mode 100644 ingester/go.sum delete mode 100644 ingester/ingester.Dockerfile delete mode 100644 ingester/logger/logger.go delete mode 100644 ingester/logger/logger_unix.go delete mode 100644 ingester/logger/logger_windows.go delete mode 100644 ingester/logger/prettyconsole.go delete mode 100644 ingester/logger/prettyconsole_test.go delete mode 100644 ingester/main.go delete mode 100644 ingester/main_test.go delete mode 100644 ingester/service/application.go delete mode 100644 ingester/service/config.go diff --git a/ingester/.gitignore b/ingester/.gitignore deleted file mode 100644 index 6f76832f92a..00000000000 --- a/ingester/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ingester diff --git a/ingester/README.md b/ingester/README.md deleted file mode 100644 index 426cd653615..00000000000 --- a/ingester/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Chainlink Ingester - -This directory contains the ingester project, which is responsible for taking -data off the chain and aggregating it for reporting or analysis purposes. - - -## Configuration - -The ingester application takes the following environment variables - -```bash -# Ethereum Chain ID for the contracts you want to listen to -ETH_CHAIN_ID -# Websocket endpoint the monitor uses to watch the aggregator contracts -ETH_URL -# Postgres database host -DB_HOST -# Postgres database name -DB_NAME -# Postgres database port -DB_PORT -# Postgres database username -DB_USERNAME -# Postgres database password -DB_PASSWORD -``` diff --git a/ingester/client/eth.go b/ingester/client/eth.go deleted file mode 100644 index 252e1f1047f..00000000000 --- a/ingester/client/eth.go +++ /dev/null @@ -1,102 +0,0 @@ -package client - -import ( - "context" - "fmt" - "math/big" - "net/url" - "time" - - "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/common/hexutil" - "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/rpc" -) - -// ETH interface represents the connection to the Ethereum node -type ETH interface { - SubscribeToLogs(chan<- types.Log, ethereum.FilterQuery) (Subscription, error) - TransactionByHash(txHash common.Hash) (*types.Transaction, error) - SubscribeToNewHeads(chan<- types.Header) (Subscription, error) -} - -type eth struct { - url *url.URL - rpc *rpc.Client - timeout time.Duration -} - -// NewClient will return a connected ETH implementation -func NewClient(urlStr string) (ETH, error) { - u, err := url.ParseRequestURI(urlStr) - if err != nil { - return nil, err - } - - rpc, err := rpc.Dial(u.String()) - return ð{ - url: u, - rpc: rpc, - }, err -} - -// TransactionByHash calls `eth_getTransactionByHash` for a given tx hash -func (c *eth) TransactionByHash(txHash common.Hash) (*types.Transaction, error) { - var tx types.Transaction - return &tx, c.rpc.Call(&tx, "eth_getTransactionByHash", txHash.String()) -} - -// SubscribeToNewHeads returns an instantiated subscription type, subscribing to heads -func (c *eth) SubscribeToNewHeads(channel chan<- types.Header) (Subscription, error) { - ctx := context.Background() - sub, err := c.rpc.EthSubscribe(ctx, channel, "newHeads") - return sub, err -} - -// Subscription is the interface for managing eth log subscriptions -type Subscription interface { - Err() <-chan error - Unsubscribe() -} - -// SubscribeToLogs returns an instantiated subscription type, subscribing to logs based on the -// given filter query -func (c *eth) SubscribeToLogs(channel chan<- types.Log, q ethereum.FilterQuery) (Subscription, error) { - ctx := context.Background() - sub, err := c.rpc.EthSubscribe(ctx, channel, "logs", toFilterArg(q)) - return sub, err -} - -func (c *eth) call(to common.Address, data []byte) ([]byte, error) { - var res string - if err := c.rpc.Call(&res, "eth_call", map[string]interface{}{ - "to": to.String(), - "data": fmt.Sprintf("0x%s", common.Bytes2Hex(data)), - }, "latest"); err != nil { - return []byte{}, err - } - return common.FromHex(res), nil -} - -// https://github.com/ethereum/go-ethereum/blob/762f3a48a00da02fe58063cb6ce8dc2d08821f15/ethclient/ethclient.go#L359 -func toFilterArg(q ethereum.FilterQuery) interface{} { - arg := map[string]interface{}{ - "fromBlock": toBlockNumArg(q.FromBlock), - "toBlock": toBlockNumArg(q.ToBlock), - "address": q.Addresses, - "topics": q.Topics, - } - if q.FromBlock == nil { - arg["fromBlock"] = "0x0" - } - return arg -} - -// https://github.com/ethereum/go-ethereum/blob/762f3a48a00da02fe58063cb6ce8dc2d08821f15/ethclient/ethclient.go#L256 -func toBlockNumArg(number *big.Int) string { - if number == nil { - return "latest" - } - return hexutil.EncodeBig(number) -} diff --git a/ingester/go.mod b/ingester/go.mod deleted file mode 100644 index 859f8f77b60..00000000000 --- a/ingester/go.mod +++ /dev/null @@ -1,21 +0,0 @@ -module ingester - -go 1.13 - -require ( - github.com/ethereum/go-ethereum v1.9.9 - github.com/fatih/color v1.3.0 - github.com/jinzhu/gorm v1.9.12 - github.com/pkg/errors v0.8.1 - github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce - github.com/satori/uuid v1.2.0 - github.com/sirupsen/logrus v1.4.2 - github.com/spf13/cobra v0.0.5 - github.com/spf13/viper v1.3.2 - github.com/stretchr/testify v1.4.0 - github.com/tevino/abool v0.0.0-20170917061928-9b9efcf221b5 // indirect - github.com/tidwall/gjson v1.5.0 - go.uber.org/multierr v1.4.0 // indirect - go.uber.org/zap v1.14.0 - gopkg.in/guregu/null.v3 v3.4.0 // indirect -) diff --git a/ingester/go.sum b/ingester/go.sum deleted file mode 100644 index 90fbcd01654..00000000000 --- a/ingester/go.sum +++ /dev/null @@ -1,265 +0,0 @@ -github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= -github.com/Azure/azure-pipeline-go v0.2.2/go.mod h1:4rQ/NZncSvGqNkkOsNpOU1tgoNuIlp9AfUH5G1tvCHc= -github.com/Azure/azure-storage-blob-go v0.7.0/go.mod h1:f9YQKtsG1nMisotuTPpO0tjNuEjKRYAcJU8/ydDI++4= -github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= -github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= -github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= -github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= -github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= -github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= -github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= -github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= -github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/OneOfOne/xxhash v1.2.5/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q= -github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= -github.com/VictoriaMetrics/fastcache v1.5.3 h1:2odJnXLbFZcoV9KYtQ+7TH1UOq3dn3AssMgieaezkR4= -github.com/VictoriaMetrics/fastcache v1.5.3/go.mod h1:+jv9Ckb+za/P1ZRg/sulP5Ni1v49daAVERr0H3CuscE= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/allegro/bigcache v1.2.1-0.20190218064605-e24eb225f156/go.mod h1:Cb/ax3seSYIx7SuZdm2G2xzfwmv3TPSk2ucNfQESPXM= -github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847 h1:rtI0fD4oG/8eVokGVPYJEW1F88p1ZNgXiEIs9thEE4A= -github.com/aristanetworks/goarista v0.0.0-20170210015632-ea17b1a17847/go.mod h1:D/tb0zPVXnP7fmsLZjtdUhSsumbK/ij54UXjjVgMGxQ= -github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973 h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= -github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= -github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.0.1-0.20190104013014-3767db7a7e18/go.mod h1:HD5P3vAIAh+Y2GAxg0PrPN1P8WkepXGpjbUPDHJqqKM= -github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cloudflare/cloudflare-go v0.10.2-0.20190916151808-a80f83b9add9/go.mod h1:1MxXX1Ux4x6mqPmjkUgTP1CdXIBXKX7T+Jk9Gxrmx+U= -github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= -github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= -github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= -github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea h1:j4317fAZh7X6GqbFowYdYdI0L9bwxL07jyPZIdepyZ0= -github.com/deckarep/golang-set v0.0.0-20180603214616-504e848d77ea/go.mod h1:93vsz/8Wt4joVM7c2AVqh+YRMiUSc14yDtF28KmMOgQ= -github.com/denisenkom/go-mssqldb v0.0.0-20191124224453-732737034ffd/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= -github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa h1:XKAhUk/dtp+CV0VO6mhG2V7jA9vbcGcnYF/Ay9NjZrY= -github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa/go.mod h1:cdorVVzy1fhmEqmtgqkoE3bYtCfSCkVyjTyCIo22xvs= -github.com/erikstmartin/go-testdb v0.0.0-20160219214506-8d10e4a1bae5/go.mod h1:a2zkGnVExMxdzMo3M0Hi/3sEU+cWnZpSni0O6/Yb/P0= -github.com/ethereum/go-ethereum v1.9.9 h1:jnoBvjH8aMH++iH14XmiJdAsnRcmZUM+B5fsnEZBVE0= -github.com/ethereum/go-ethereum v1.9.9/go.mod h1:a9TqabFudpDu1nucId+k9S8R9whYaHnGBLKFouA5EAo= -github.com/fatih/color v1.3.0 h1:YehCCcyeQ6Km0D6+IapqPinWBK6y+0eB5umvZXK9WPs= -github.com/fatih/color v1.3.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fjl/memsize v0.0.0-20180418122429-ca190fb6ffbc/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= -github.com/go-sql-driver/mysql v1.4.1/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= -github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogo/protobuf v1.1.1 h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2-0.20190517061210-b285ee9cfc6c h1:zqAKixg3cTcIasAMJV+EcfVbWwLpOZ7LeoWJvcuD/5Q= -github.com/golang/protobuf v1.3.2-0.20190517061210-b285ee9cfc6c/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/snappy v0.0.1 h1:Qgr9rKW7uDUkrbSmQeiDsGa8SjGyCOGtuasMWwvp2P4= -github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989 h1:giknQ4mEuDFmmHSrGcbargOuLHQGtywqo4mheITex54= -github.com/gorilla/websocket v1.4.1-0.20190629185528-ae1634f6a989/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= -github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc= -github.com/hashicorp/golang-lru v0.0.0-20160813221303-0a025b7e63ad/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/huin/goupnp v0.0.0-20161224104101-679507af18f3/go.mod h1:MZ2ZmwcBpvOoJ22IJsc7va19ZwoheaBk43rKg12SKag= -github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY= -github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= -github.com/jinzhu/gorm v1.9.12 h1:Drgk1clyWT9t9ERbzHza6Mj/8FY/CqMyVzOiHviMo6Q= -github.com/jinzhu/gorm v1.9.12/go.mod h1:vhTjlKSJUTWNtcbQtrMBFCxy7eXTzeCAzfL5fBZT/Qs= -github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= -github.com/jinzhu/now v1.0.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= -github.com/julienschmidt/httprouter v1.1.1-0.20170430222011-975b5c4c7c21/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/lib/pq v1.1.1 h1:sJZmqHoEaY7f+NPP8pgLB/WxulyR3fewgCM2qaSlBb4= -github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= -github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/mattn/go-colorable v0.1.0 h1:v2XXALHHh6zHfYTJ+cSkwtyffnaOyR1MXaA91mTrb8o= -github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-ieproxy v0.0.0-20190610004146-91bb50d98149/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= -github.com/mattn/go-ieproxy v0.0.0-20190702010315-6dee0af9227d/go.mod h1:31jz6HNzdxOmlERGGEc4v/dMssOfmp2p5bT/okiKFFc= -github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035 h1:USWjF42jDCSEeikX/G1g40ZWnsPXN5WkZ4jMHZWyBK4= -github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-sqlite3 v2.0.1+incompatible/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/naoina/go-stringutil v0.1.0/go.mod h1:XJ2SJL9jCtBh+P9q5btrd/Ylo8XwT/h1USek5+NqSA0= -github.com/naoina/toml v0.1.2-0.20170918210437-9fafd6967416/go.mod h1:NBIhNtsFMo3G2szEBne+bO4gS192HuIYRqfvOWb4i1E= -github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/olekukonko/tablewriter v0.0.1/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/olekukonko/tablewriter v0.0.2-0.20190409134802-7e037d187b0c/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= -github.com/pborman/uuid v0.0.0-20170112150404-1b00554d8222/go.mod h1:VyrYX9gd7irzKovcSS6BIIEwPRkP2Wm2m9ufcdFSJ34= -github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= -github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= -github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1 h1:K47Rk0v/fkEfwfQet2KWhscE0cJzjgCCDBG2KHZoVno= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce h1:X0jFYGnHemYDIW6jlc+fSI8f9Cg+jqCnClYP2WgZT/A= -github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d h1:GoAlyOgbOEIFdaDqxJVlbOQ1DtGmZWs/Qau0hIlk+WQ= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/tsdb v0.6.2-0.20190402121629-4f204dcbc150/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= -github.com/rjeczalik/notify v0.9.1/go.mod h1:rKwnCoCGeuQnwBtTSPL9Dad03Vh2n40ePRrjvIXnJho= -github.com/robertkrimen/otto v0.0.0-20170205013659-6a77b7cbc37d/go.mod h1:xvqspoSXJTIpemEonrMDFq6XzwHYYgToXWj5eRX1OtY= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00 h1:8DPul/X0IT/1TNMIxoKLwdemEOBBHDC/K4EB16Cw5WE= -github.com/rs/cors v0.0.0-20160617231935-a62a804a8a00/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= -github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521 h1:3hxavr+IHMsQBrYUPQM5v0CgENFktkkbg1sfpgM3h20= -github.com/rs/xhandler v0.0.0-20160618193221-ed27b6fd6521/go.mod h1:RvLn4FgxWubrpZHtQLnOf6EwhN2hEMusxZOhcW9H3UQ= -github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= -github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= -github.com/satori/uuid v1.2.0/go.mod h1:B8HLsPLik/YNn6KKWVMDJ8nzCL8RP5WyfsnmvnAEwIU= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.0.1-0.20190317074736-539464a789e9/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI= -github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= -github.com/spf13/cast v1.3.0 h1:oget//CVOEoFewqQxwr0Ej5yjygnqGkvggSE/gB35Q8= -github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s= -github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU= -github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= -github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= -github.com/spf13/pflag v1.0.3 h1:zPAT6CGy6wXeQ7NtTnaTerfKOsV6V6F8agHXFiazDkg= -github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= -github.com/spf13/viper v1.3.2 h1:VUFqw5KcqRf7i70GOzW7N+Q7+gxVBkSSqiXB12+JQ4M= -github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s= -github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= -github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570 h1:gIlAHnH1vJb5vwEjIp5kBj/eu99p/bl0Ay2goiPe5xE= -github.com/steakknife/bloomfilter v0.0.0-20180922174646-6819c0d2a570/go.mod h1:8OR4w3TdeIHIh1g6EMY5p0gVNOovcWC+1vpc7naMuAw= -github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3 h1:njlZPzLwU639dk2kqnCPPv+wNjq7Xb6EfUxe/oX0/NM= -github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/syndtr/goleveldb v1.0.1-0.20190923125748-758128399b1d/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= -github.com/tevino/abool v0.0.0-20170917061928-9b9efcf221b5 h1:hNna6Fi0eP1f2sMBe/rJicDmaHmoXGe1Ta84FPYHLuE= -github.com/tevino/abool v0.0.0-20170917061928-9b9efcf221b5/go.mod h1:f1SCnEOt6sc3fOJfPQDRDzHOtSXuTtnz0ImG9kPRDV0= -github.com/tidwall/gjson v1.5.0 h1:QCssIUI7J0RStkzIcI4A7O6P8rDA5wi5IPf70uqKSxg= -github.com/tidwall/gjson v1.5.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls= -github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc= -github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= -github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= -github.com/tyler-smith/go-bip39 v1.0.1-0.20181017060643-dbb3b84ba2ef/go.mod h1:sJ5fKU0s6JVwZjjcUEX2zFOnvq0ASQ2K9Zr6cf67kNs= -github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= -github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= -github.com/wsddn/go-ecdh v0.0.0-20161211032359-48726bab9208/go.mod h1:IotVbo4F+mw0EzQ08zFqg7pK3FebNXpaMsRy2RT+Ees= -github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= -go.uber.org/atomic v1.5.0 h1:OI5t8sDa1Or+q8AeE+yKeB/SDYioSHAgcVljj9JIETY= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.4.0 h1:f3WCSC2KzAcBXGATIxAB1E2XuCpNU255wNKZ505qi3E= -go.uber.org/multierr v1.4.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.14.0 h1:/pduUoebOeeJzTDFuoMgC6nRkiasr1sBCIEorly7m4o= -go.uber.org/zap v1.14.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529 h1:iMGN4xG0cnqj3t+zOM8wUB0BiPKHEwSxEZCvzcbZuvk= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd h1:GGJVjV8waZKRHrgwvtH66z9ZGVurTD1MT0n1Bb+q4aM= -golang.org/x/crypto v0.0.0-20191205180655-e7c4368fe9dd/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7 h1:rTIdg5QFRR7XCaK4LCjBiPbx8j4DQRpdYMnGn/bJUEU= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7 h1:LepdCS8Gf/MVejFIt8lsiexZATdoGVyp5bcyS+rYoUI= -golang.org/x/sys v0.0.0-20190712062909-fae7ac547cb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/guregu/null.v3 v3.4.0 h1:AOpMtZ85uElRhQjEDsFx21BkXqFPwA7uoJukd4KErIs= -gopkg.in/guregu/null.v3 v3.4.0/go.mod h1:E4tX2Qe3h7QdL+uZ3a0vqvYwKQsRSQKM5V4YltdgH9Y= -gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= -gopkg.in/olebedev/go-duktape.v3 v3.0.0-20190213234257-ec84240a7772/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns= -gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/ingester/ingester.Dockerfile b/ingester/ingester.Dockerfile deleted file mode 100644 index a2975449fcd..00000000000 --- a/ingester/ingester.Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM golang:1.13-alpine as builder - -RUN apk add --no-cache make curl git g++ gcc musl-dev linux-headers - -WORKDIR /usr/local/src/chainlink/ingester - -# Do go mod download in a cacheable step -ADD ingester/go.mod ingester/go.sum ./ -RUN go mod download - -# Build the ingester binary -ADD ingester . -RUN go build - -# Copy into a second stage container -FROM alpine:latest - -RUN apk add --no-cache ca-certificates -COPY --from=builder /usr/local/src/chainlink/ingester/ingester /usr/local/bin/ - -ENTRYPOINT ["ingester"] diff --git a/ingester/logger/logger.go b/ingester/logger/logger.go deleted file mode 100644 index d6875c71dbb..00000000000 --- a/ingester/logger/logger.go +++ /dev/null @@ -1,211 +0,0 @@ -// Package logger is used to store details of events in the node. -// Events can be categorized by Debug, Info, Error, Fatal, and Panic. -package logger - -import ( - "fmt" - "log" - "net/url" - "os" - - "github.com/fatih/color" - "github.com/pkg/errors" - "go.uber.org/zap" - "go.uber.org/zap/zapcore" -) - -var logger *Logger - -func init() { - err := zap.RegisterSink("pretty", prettyConsoleSink(os.Stderr)) - if err != nil { - log.Fatalf("failed to register pretty printer %+v", err) - } - err = registerOSSinks() - if err != nil { - log.Fatalf("failed to register os specific sinks %+v", err) - } - - zl, err := zap.NewProduction() - if err != nil { - log.Fatal(err) - } - SetLogger(zl) -} - -func GetLogger() *Logger { - return logger -} - -func prettyConsoleSink(s zap.Sink) func(*url.URL) (zap.Sink, error) { - return func(*url.URL) (zap.Sink, error) { - return PrettyConsole{s}, nil - } -} - -// Logger holds a field for the logger interface. -type Logger struct { - *zap.SugaredLogger -} - -// Write logs a message at the Info level and returns the length -// of the given bytes. -func (l *Logger) Write(b []byte) (int, error) { - l.Info(string(b)) - return len(b), nil -} - -// SetLogger sets the internal logger to the given input. -func SetLogger(zl *zap.Logger) { - if logger != nil { - defer logger.Sync() - } - logger = &Logger{zl.Sugar()} -} - -// CreateProductionLogger returns a log config for the passed directory -// with the given LogLevel and customizes stdout for pretty printing. -func CreateProductionLogger( - dir string, jsonConsole bool, lvl zapcore.Level, toDisk bool) *zap.Logger { - config := zap.NewProductionConfig() - if !jsonConsole { - config.OutputPaths = []string{"pretty://console"} - } - if toDisk { - destination := logFileURI(dir) - config.OutputPaths = append(config.OutputPaths, destination) - config.ErrorOutputPaths = append(config.ErrorOutputPaths, destination) - } - config.Level.SetLevel(lvl) - - zl, err := config.Build(zap.AddCallerSkip(1)) - if err != nil { - log.Fatal(err) - } - return zl -} - -// CreateTestLogger creates a logger that directs output to PrettyConsole -// configured for test output. -func CreateTestLogger(lvl zapcore.Level) *zap.Logger { - color.NoColor = false - config := zap.NewProductionConfig() - config.Level.SetLevel(lvl) - config.OutputPaths = []string{"pretty://console"} - zl, err := config.Build(zap.AddCallerSkip(1)) - if err != nil { - log.Fatal(err) - } - return zl -} - -// Infow logs an info message and any additional given information. -func Infow(msg string, keysAndValues ...interface{}) { - logger.Infow(msg, keysAndValues...) -} - -// Debugw logs a debug message and any additional given information. -func Debugw(msg string, keysAndValues ...interface{}) { - logger.Debugw(msg, keysAndValues...) -} - -// Warnw logs a debug message and any additional given information. -func Warnw(msg string, keysAndValues ...interface{}) { - logger.Warnw(msg, keysAndValues...) -} - -// Errorw logs an error message, any additional given information, and includes -// stack trace. -func Errorw(msg string, keysAndValues ...interface{}) { - logger.Errorw(msg, keysAndValues...) -} - -// Infof formats and then logs the message. -func Infof(format string, values ...interface{}) { - logger.Info(fmt.Sprintf(format, values...)) -} - -// Debugf formats and then logs the message. -func Debugf(format string, values ...interface{}) { - logger.Debug(fmt.Sprintf(format, values...)) -} - -// Warnf formats and then logs the message as Warn. -func Warnf(format string, values ...interface{}) { - logger.Warn(fmt.Sprintf(format, values...)) -} - -// Panicf formats and then logs the message before panicking. -func Panicf(format string, values ...interface{}) { - logger.Panic(fmt.Sprintf(format, values...)) -} - -// Info logs an info message. -func Info(args ...interface{}) { - logger.Info(args...) -} - -// Debug logs a debug message. -func Debug(args ...interface{}) { - logger.Debug(args...) -} - -// Warn logs a message at the warn level. -func Warn(args ...interface{}) { - logger.Warn(args...) -} - -// Error logs an error message. -func Error(args ...interface{}) { - logger.Error(args...) -} - -// WarnIf logs the error if present. -func WarnIf(err error) { - if err != nil { - logger.Warn(err) - } -} - -// ErrorIf logs the error if present. -func ErrorIf(err error, optionalMsg ...string) { - if err != nil { - if len(optionalMsg) > 0 { - logger.Error(errors.Wrap(err, optionalMsg[0])) - } else { - logger.Error(err) - } - } -} - -// PanicIf logs the error if present. -func PanicIf(err error) { - if err != nil { - logger.Panic(err) - } -} - -// Fatal logs a fatal message then exits the application. -func Fatal(args ...interface{}) { - logger.Fatal(args...) -} - -// Errorf logs a message at the error level using Sprintf. -func Errorf(format string, values ...interface{}) { - Error(fmt.Sprintf(format, values...)) -} - -// Fatalf logs a message at the fatal level using Sprintf. -func Fatalf(format string, values ...interface{}) { - Fatal(fmt.Sprintf(format, values...)) -} - -// Panic logs a panic message then panics. -func Panic(args ...interface{}) { - logger.Panic(args...) -} - -// Sync flushes any buffered log entries. -func Sync() error { - return logger.Sync() -} diff --git a/ingester/logger/logger_unix.go b/ingester/logger/logger_unix.go deleted file mode 100644 index 7af4afe9ee2..00000000000 --- a/ingester/logger/logger_unix.go +++ /dev/null @@ -1,15 +0,0 @@ -// +build !windows - -package logger - -import "path/filepath" - -func registerOSSinks() error { - return nil -} - -// logFileURI returns the full path to the file the -// ProductionLogger logs to, and uses zap's built in default file sink. -func logFileURI(configRootDir string) string { - return filepath.ToSlash(filepath.Join(configRootDir, "log.jsonl")) -} diff --git a/ingester/logger/logger_windows.go b/ingester/logger/logger_windows.go deleted file mode 100644 index caa154519d7..00000000000 --- a/ingester/logger/logger_windows.go +++ /dev/null @@ -1,29 +0,0 @@ -// +build windows - -package logger - -import ( - "net/url" - "os" - "path/filepath" - - "go.uber.org/zap" -) - -// logFileURI returns the scheme and path to the log file for the passed -// directory, with a custom scheme winfile:/// specifically tailored for -// Windows to get around their handling of the file:// schema in uber.org/zap. -// https://github.com/uber-go/zap/issues/621 -func logFileURI(configRootDir string) string { - return "winfile:///" + filepath.ToSlash(filepath.Join(configRootDir, "log.jsonl")) -} - -func registerOSSinks() error { - return zap.RegisterSink("winfile", newWinFileSink) -} - -func newWinFileSink(u *url.URL) (zap.Sink, error) { - // https://github.com/uber-go/zap/issues/621 - // Remove leading slash left by url.Parse() - return os.OpenFile(u.Path[1:], os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644) -} diff --git a/ingester/logger/prettyconsole.go b/ingester/logger/prettyconsole.go deleted file mode 100644 index 0498d1b5b6f..00000000000 --- a/ingester/logger/prettyconsole.go +++ /dev/null @@ -1,103 +0,0 @@ -package logger - -import ( - "fmt" - "math" - "sort" - "strings" - "time" - - "github.com/fatih/color" - "github.com/tidwall/gjson" - "go.uber.org/zap" -) - -var levelColors = map[string]func(...interface{}) string{ - "default": color.New(color.FgWhite).SprintFunc(), - "debug": color.New(color.FgGreen).SprintFunc(), - "info": color.New(color.FgWhite).SprintFunc(), - "warn": color.New(color.FgYellow).SprintFunc(), - "error": color.New(color.FgRed).SprintFunc(), - "panic": color.New(color.FgRed).SprintFunc(), - "fatal": color.New(color.FgRed).SprintFunc(), -} - -var blue = color.New(color.FgBlue).SprintFunc() -var green = color.New(color.FgGreen).SprintFunc() - -// PrettyConsole wraps a Sink (Writer, Syncer, Closer), usually stdout, and -// formats the incoming json bytes with colors and white space for readability -// before passing on to the underlying Writer in Sink. -type PrettyConsole struct { - zap.Sink -} - -// Write reformats the incoming json bytes with colors, newlines and whitespace -// for better readability in console. -func (pc PrettyConsole) Write(b []byte) (int, error) { - if !gjson.ValidBytes(b) { - return 0, fmt.Errorf("Unable to parse json for pretty console: %s", string(b)) - } - js := gjson.ParseBytes(b) - headline := generateHeadline(js) - details := generateDetails(js) - return pc.Sink.Write([]byte(fmt.Sprintln(headline, details))) -} - -func generateHeadline(js gjson.Result) string { - sec, dec := math.Modf(js.Get("ts").Float()) - headline := []interface{}{ - ISO8601UTC(time.Unix(int64(sec), int64(dec*(1e9)))), - " ", - coloredLevel(js.Get("level")), - fmt.Sprintf("%-50s", js.Get("msg")), - " ", - fmt.Sprintf("%-32s", blue(js.Get("caller"))), - } - return fmt.Sprint(headline...) -} - -// detailsBlacklist of keys to show in details. This does not -// exclude it from being present in other logger sinks, like .jsonl files. -var detailsBlacklist = map[string]bool{ - "level": true, - "ts": true, - "msg": true, - "caller": true, - "hash": true, -} - -func generateDetails(js gjson.Result) string { - data := js.Map() - keys := []string{} - - for k := range data { - if detailsBlacklist[k] || len(data[k].String()) == 0 { - continue - } - keys = append(keys, k) - } - - sort.Strings(keys) - - var details strings.Builder - - for _, v := range keys { - details.WriteString(fmt.Sprintf("%s=%v ", green(v), data[v])) - } - - return details.String() -} - -func coloredLevel(level gjson.Result) string { - color, ok := levelColors[level.String()] - if !ok { - color = levelColors["default"] - } - return color(fmt.Sprintf("%-8s", fmt.Sprint("[", strings.ToUpper(level.String()), "]"))) -} - -// ISO8601UTC formats given time to ISO8601. -func ISO8601UTC(t time.Time) string { - return t.UTC().Format(time.RFC3339) -} diff --git a/ingester/logger/prettyconsole_test.go b/ingester/logger/prettyconsole_test.go deleted file mode 100644 index 79693b33702..00000000000 --- a/ingester/logger/prettyconsole_test.go +++ /dev/null @@ -1,65 +0,0 @@ -package logger - -import ( - "testing" - - "github.com/fatih/color" - "github.com/stretchr/testify/assert" -) - -func TestPrettyConsole_Write(t *testing.T) { - color.NoColor = false - - tests := []struct { - name string - input string - want string - wantError bool - }{ - { - "headline", - `{"ts":1523537728.7260377, "level":"info", "msg":"top level"}`, - "2018-04-12T12:55:28Z \x1b[37m[INFO] \x1b[0mtop level \x1b[34m\x1b[0m \n", - false, - }, - { - "details", - `{"ts":1523537728, "level":"debug", "msg":"top level", "details":"nuances"}`, - "2018-04-12T12:55:28Z \x1b[32m[DEBUG] \x1b[0mtop level \x1b[34m\x1b[0m \x1b[32mdetails\x1b[0m=nuances \n", - false, - }, - { - "blacklist", - `{"ts":1523537728, "level":"warn", "msg":"top level", "hash":"nuances"}`, - "2018-04-12T12:55:28Z \x1b[33m[WARN] \x1b[0mtop level \x1b[34m\x1b[0m \n", - false, - }, - {"error", `{"broken":}`, `{}`, true}, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - tr := &testReader{} - pc := PrettyConsole{tr} - _, err := pc.Write([]byte(tt.input)) - - if tt.wantError { - assert.Error(t, err) - } else { - assert.Equal(t, tt.want, tr.Written) - } - }) - } -} - -type testReader struct { - Written string -} - -func (*testReader) Sync() error { return nil } -func (*testReader) Close() error { return nil } - -func (tr *testReader) Write(b []byte) (int, error) { - tr.Written = string(b) - return 0, nil -} diff --git a/ingester/main.go b/ingester/main.go deleted file mode 100644 index 3b5a8f46334..00000000000 --- a/ingester/main.go +++ /dev/null @@ -1,48 +0,0 @@ -package main - -import ( - "os" - "os/signal" - "time" - - "ingester/logger" - "ingester/service" - - "github.com/spf13/cobra" -) - -type runner func(*service.Config) (*service.Application, error) - -func init() { - time.LoadLocation("UTC") -} - -func generateCmd() *cobra.Command { - newcmd := &cobra.Command{ - Use: "ingester", - Args: cobra.MaximumNArgs(0), - Long: "Manages ingestion tasks for the ethereum blockchain", - Run: func(_ *cobra.Command, _ []string) { run(service.NewApplication) }, - } - return newcmd -} - -func run(r runner) { - a, err := r(service.DefaultConfig()) - if err != nil { - logger.Fatalf("Failed to create application: %+v", err) - } - - a.Start(func() { - sig := make(chan os.Signal, 1) - signal.Notify(sig, os.Interrupt) - <-sig - }) - a.Stop() -} - -func main() { - if err := generateCmd().Execute(); err != nil { - logger.Warn(err) - } -} diff --git a/ingester/main_test.go b/ingester/main_test.go deleted file mode 100644 index 270433983b7..00000000000 --- a/ingester/main_test.go +++ /dev/null @@ -1,73 +0,0 @@ -// +build !windows - -package main - -import ( - "io/ioutil" - "testing" - - "github.com/smartcontractkit/chainlink/core/cmd" - "github.com/smartcontractkit/chainlink/core/internal/cltest" -) - -func ExampleRun() { - t := &testing.T{} - tc, cleanup := cltest.NewConfig(t) - defer cleanup() - tc.Config.Set("CHAINLINK_DEV", false) - testClient := &cmd.Client{ - Renderer: cmd.RendererTable{Writer: ioutil.Discard}, - Config: tc.Config, - AppFactory: cmd.ChainlinkAppFactory{}, - KeyStoreAuthenticator: cmd.TerminalKeyStoreAuthenticator{Prompter: &cltest.MockCountingPrompter{}}, - FallbackAPIInitializer: &cltest.MockAPIInitializer{}, - Runner: cmd.ChainlinkRunner{}, - HTTP: cltest.NewMockAuthenticatedHTTPClient(tc.Config), - ChangePasswordPrompter: cltest.MockChangePasswordPrompter{}, - } - - Run(testClient, "core.test", "--help") - // Output: - // NAME: - // core.test - CLI for Chainlink - // - // USAGE: - // core.test [global options] command [command options] [arguments...] - // - // VERSION: - // unset@unset - // - // COMMANDS: - // admin Commands for remotely taking admin related actions - // bridges Commands for Bridges communicating with External Adapters - // config Commands for the node's configuration - // jobs Commands for managing Jobs - // node, local Commands for admin actions that must be run locally - // runs Commands for managing Runs - // txs Commands for handling Ethereum transactions - // help, h Shows a list of commands or help for one command - // - // GLOBAL OPTIONS: - // --json, -j json output as opposed to table - // --help, -h show help - // --version, -v print the version -} - -func ExampleVersion() { - t := &testing.T{} - tc, cleanup := cltest.NewConfig(t) - defer cleanup() - testClient := &cmd.Client{ - Renderer: cmd.RendererTable{Writer: ioutil.Discard}, - Config: tc.Config, - AppFactory: cmd.ChainlinkAppFactory{}, - KeyStoreAuthenticator: cmd.TerminalKeyStoreAuthenticator{Prompter: &cltest.MockCountingPrompter{}}, - FallbackAPIInitializer: &cltest.MockAPIInitializer{}, - Runner: cmd.ChainlinkRunner{}, - HTTP: cltest.NewMockAuthenticatedHTTPClient(tc.Config), - } - - Run(testClient, "core.test", "--version") - // Output: - // core.test version unset@unset -} diff --git a/ingester/service/application.go b/ingester/service/application.go deleted file mode 100644 index 5fab9080748..00000000000 --- a/ingester/service/application.go +++ /dev/null @@ -1,150 +0,0 @@ -package service - -import ( - "database/sql" - "fmt" - - "ingester/client" - "ingester/logger" - - "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/core/types" - _ "github.com/jinzhu/gorm/dialects/postgres" // http://doc.gorm.io/database.html#connecting-to-a-database -) - -// Application is an instance of the aggregator monitor application containing -// all clients and services -type Application struct { - Config *Config - - ETHClient client.ETH -} - -// InterruptHandler is a function that is called after application startup -// designed to wait based on a specified interrupt -type InterruptHandler func() - -// NewApplication returns an instance of the Application with -// all clients connected and services instantiated -func NewApplication(config *Config) (*Application, error) { - logger.SetLogger(logger.CreateTestLogger(-1)) - - logger.Infow( - "Starting the Chainlink Ingester", - "eth-url", config.EthereumURL, - "eth-chain-id", config.NetworkID, - "db-host", config.DatabaseHost, - "db-name", config.DatabaseName, - "db-port", config.DatabasePort, - "db-username", config.DatabaseUsername, - ) - - ec, err := client.NewClient(config.EthereumURL) - if err != nil { - return nil, fmt.Errorf("Failed to connect to ETH client: %+v", err) - } - - psqlInfo := fmt.Sprintf( - "host=%s port=%d user=%s password=%s dbname=%s sslmode=disable", - config.DatabaseHost, - config.DatabasePort, - config.DatabaseUsername, - config.DatabasePassword, - config.DatabaseName, - ) - db, err := sql.Open("postgres", psqlInfo) - if err != nil { - return nil, err - } - err = db.Ping() - if err != nil { - return nil, err - } - - q := ethereum.FilterQuery{} - logChan := make(chan types.Log) - _, err = ec.SubscribeToLogs(logChan, q) - if err != nil { - return nil, err - } - - go func() { - logger.Debug("Listening for logs") - for log := range logChan { - address := make([]byte, 20) - copy(address, log.Address[:]) - - topics := make([]byte, len(log.Topics)*len(common.Hash{})) - for index, topic := range log.Topics { - copy(topics[index*len(common.Hash{}):], topic.Bytes()) - } - - logger.Debugw("Oberved new log", "blockHash", log.BlockHash, "index", log.Index, "removed", log.Removed) - _, err := db.Exec(`INSERT INTO "ethereum_log" ("address", "topics", "data", "blockNumber", "txHash", "txIndex", "blockHash", "index", "removed") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9);`, - address, - topics, - log.Data, - log.BlockNumber, - log.TxHash.Bytes(), - log.TxIndex, - log.BlockHash.Bytes(), - log.Index, - log.Removed) - if err != nil { - logger.Errorw("Insert failed", "error", err) - } - } - }() - - headChan := make(chan types.Header) - _, err = ec.SubscribeToNewHeads(headChan) - if err != nil { - return nil, err - } - - go func() { - logger.Debug("Listening for heads") - for head := range headChan { - nonce := make([]byte, 8) - copy(nonce, head.Nonce[:]) - - logger.Debugw("Observed new head", "blockHeight", head.Number, "blockHash", head.Hash()) - _, err := db.Exec(`INSERT INTO "ethereum_head" ("blockHash", "parentHash", "uncleHash", "coinbase", "root", "txHash", "receiptHash", "bloom", "difficulty", "number", "gasLimit", "gasUsed", "time", "extra", "mixDigest", "nonce") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16);`, - head.Hash().Bytes(), - head.ParentHash, - head.UncleHash, - head.Coinbase, - head.Root, - head.TxHash, - head.ReceiptHash, - head.Bloom.Bytes(), - head.Difficulty.String(), - head.Number.String(), - head.GasLimit, - head.GasUsed, - head.Time, - head.Extra, - head.MixDigest, - nonce) - if err != nil { - logger.Errorw("Insert failed", "error", err) - } - } - }() - - return &Application{ - ETHClient: ec, - Config: config, - }, nil -} - -// Start will start all the services within the application and call the interrupt handler -func (a *Application) Start(ih InterruptHandler) { - ih() -} - -// Stop will call each services that requires a clean shutdown to stop -func (a *Application) Stop() { - logger.Info("Shutting down") -} diff --git a/ingester/service/config.go b/ingester/service/config.go deleted file mode 100644 index c808d715759..00000000000 --- a/ingester/service/config.go +++ /dev/null @@ -1,63 +0,0 @@ -package service - -import ( - "strings" - "time" - - "github.com/spf13/viper" -) - -// Config contains the startup parameters to configure the monitor -type Config struct { - // ResponseTimeout is the duration to wait before the response is treated as timed-out to alert on - ResponseTimeout time.Duration `mapstructure:"response-timeout"` - // NetworkID is the Ethereum Chain ID for the contracts you want to listen to - NetworkID int `mapstructure:"eth-chain-id"` - // EthereumURL is the websocket endpoint the monitor uses to watch the aggregator contracts - EthereumURL string `mapstructure:"eth-url"` - // DatabaseHost of the postgres server where the ingester saves results - DatabaseHost string `mapstructure:"db-host"` - // DatabaseName of the postgres server where the ingester saves results - DatabaseName string `mapstructure:"db-name"` - // DatabasePort of the postgres server where the ingester saves results - DatabasePort int `mapstructure:"db-port"` - // DatabaseUsername of the postgres server where the ingester saves results - DatabaseUsername string `mapstructure:"db-username"` - // DatabasePassword of the postgres server where the ingester saves results - DatabasePassword string `mapstructure:"db-password"` -} - -// NewConfig will return an instantiated config based on the passed in defaults -// and the environment variables as defined in the config struct -func NewConfig(defaults map[string]interface{}) *Config { - v := viper.New() - c := Config{} - for key, value := range defaults { - v.SetDefault(key, value) - } - v.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) - v.AutomaticEnv() - _ = v.ReadInConfig() - _ = v.Unmarshal(&c) - return &c -} - -// DefaultConfig returns an instantiated config with the application defaults -func DefaultConfig() *Config { - return NewConfig(map[string]interface{}{ - "response-timeout": time.Minute * 5, - "eth-chain-id": 1, - "eth-url": "ws://localhost:8545", - "db-host": "localhost", - "db-name": "explorer", - "db-port": "5432", - "db-username": "postgres", - "db-password": "postgres", - }) -} - -// DefaultConfig returns an instantiated config with the application defaults for testing -func TestConfig() *Config { - cfg := DefaultConfig() - return cfg -}