review fixes

This commit is contained in:
Ian Norden
2019-12-02 13:24:58 -06:00
parent 2244d1869f
commit 0bbb7a30d1
34 changed files with 253 additions and 469 deletions
+1 -1
View File
@@ -40,7 +40,7 @@ var (
cfgFile string
databaseConfig config.Database
genConfig config.Plugin
subConfig config.Subscription
subscriptionConfig config.Subscription
ipc string
levelDbPath string
queueRecheckInterval time.Duration
+8 -8
View File
@@ -33,14 +33,14 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
"github.com/vulcanize/vulcanizedb/pkg/ipfs"
)
// streamSubscribeCmd represents the streamSubscribe command
var streamSubscribeCmd = &cobra.Command{
Use: "streamSubscribe",
Short: "This command is used to subscribe to the seed node stream with the provided filters",
Long: ``,
Long: `This command is for demo and testing purposes and is used to subscribe to the seed node with the provided subscription configuration parameters.
It does not do anything with the data streamed from the seed node other than unpack it and print it out for demonstration purposes.`,
Run: func(cmd *cobra.Command, args []string) {
streamSubscribe()
},
@@ -52,17 +52,17 @@ func init() {
func streamSubscribe() {
// Prep the subscription config/filters to be sent to the server
subscriptionConfig()
configureSubscription()
// Create a new rpc client and a subscription streamer with that client
rpcClient := getRpcClient()
str := streamer.NewSeedStreamer(rpcClient)
str := streamer.NewSeedNodeStreamer(rpcClient)
// Buffered channel for reading subscription payloads
payloadChan := make(chan ipfs.ResponsePayload, 20000)
payloadChan := make(chan streamer.SeedNodePayload, 20000)
// Subscribe to the seed node service with the given config/filter parameters
sub, err := str.Stream(payloadChan, subConfig)
sub, err := str.Stream(payloadChan, subscriptionConfig)
if err != nil {
log.Fatal(err)
}
@@ -161,9 +161,9 @@ func streamSubscribe() {
}
}
func subscriptionConfig() {
func configureSubscription() {
log.Info("loading subscription config")
subConfig = config.Subscription{
subscriptionConfig = config.Subscription{
// Below default to false, which means we do not backfill by default
BackFill: viper.GetBool("subscription.backfill"),
BackFillOnly: viper.GetBool("subscription.backfillOnly"),
+3 -2
View File
@@ -20,6 +20,8 @@ import (
"path/filepath"
syn "sync"
"github.com/vulcanize/vulcanizedb/pkg/seed_node"
"github.com/spf13/viper"
log "github.com/sirupsen/logrus"
@@ -33,7 +35,6 @@ import (
"github.com/vulcanize/vulcanizedb/pkg/geth/client"
vRpc "github.com/vulcanize/vulcanizedb/pkg/geth/converters/rpc"
"github.com/vulcanize/vulcanizedb/pkg/geth/node"
"github.com/vulcanize/vulcanizedb/pkg/ipfs"
"github.com/vulcanize/vulcanizedb/utils"
)
@@ -68,7 +69,7 @@ func syncAndPublish() {
}
ipfsPath = filepath.Join(home, ".ipfs")
}
processor, err := ipfs.NewIPFSProcessor(ipfsPath, &db, ethClient, rpcClient, quitChan)
processor, err := seed_node.NewProcessor(ipfsPath, &db, ethClient, rpcClient, quitChan)
if err != nil {
log.Fatal(err)
}
+6 -2
View File
@@ -20,6 +20,8 @@ import (
"path/filepath"
syn "sync"
"github.com/vulcanize/vulcanizedb/pkg/seed_node"
"github.com/ethereum/go-ethereum/rpc"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -61,7 +63,7 @@ func syncPublishScreenAndServe() {
}
ipfsPath = filepath.Join(home, ".ipfs")
}
processor, err := ipfs.NewIPFSProcessor(ipfsPath, &db, ethClient, rpcClient, quitChan)
processor, err := seed_node.NewProcessor(ipfsPath, &db, ethClient, rpcClient, quitChan)
if err != nil {
log.Fatal(err)
}
@@ -94,7 +96,9 @@ func syncPublishScreenAndServe() {
if wsEndpoint == "" {
wsEndpoint = "127.0.0.1:80"
}
_, _, err = rpc.StartWSEndpoint(wsEndpoint, processor.APIs(), []string{"vulcanizedb"}, nil, true)
var exposeAll = true
var wsOrigins []string = nil
_, _, err = rpc.StartWSEndpoint(wsEndpoint, processor.APIs(), []string{"vulcanizedb"}, wsOrigins, exposeAll)
if err != nil {
log.Fatal(err)
}