getter rpc method for the seed node's geth info

This commit is contained in:
Ian Norden 2019-09-13 14:41:50 -05:00
parent 2c997921cb
commit 8fe273fb7b
4 changed files with 19 additions and 3 deletions

View File

@ -73,7 +73,7 @@ func syncAndPublish() {
if workers < 1 { if workers < 1 {
workers = 1 workers = 1
} }
processor, err := seed_node.NewSeedNode(ipfsPath, &db, rpcClient, quitChan, workers) processor, err := seed_node.NewSeedNode(ipfsPath, &db, rpcClient, quitChan, workers, blockChain.Node())
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -67,7 +67,7 @@ func syncPublishScreenAndServe() {
if workers < 1 { if workers < 1 {
workers = 1 workers = 1
} }
processor, err := seed_node.NewSeedNode(ipfsPath, &db, rpcClient, quitChan, workers) processor, err := seed_node.NewSeedNode(ipfsPath, &db, rpcClient, quitChan, workers, blockChain.Node())
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -24,6 +24,7 @@ import (
"github.com/vulcanize/vulcanizedb/libraries/shared/streamer" "github.com/vulcanize/vulcanizedb/libraries/shared/streamer"
"github.com/vulcanize/vulcanizedb/pkg/config" "github.com/vulcanize/vulcanizedb/pkg/config"
"github.com/vulcanize/vulcanizedb/pkg/core"
) )
// APIName is the namespace used for the state diffing service API // APIName is the namespace used for the state diffing service API
@ -82,3 +83,8 @@ func (api *PublicSeedNodeAPI) Stream(ctx context.Context, streamFilters config.S
return rpcSub, nil return rpcSub, nil
} }
// Node is a public rpc method to allow transformers to fetch the Geth node info for the seed node
func (api *PublicSeedNodeAPI) Node() core.Node {
return api.sni.Node()
}

View File

@ -52,6 +52,8 @@ type NodeInterface interface {
Subscribe(id rpc.ID, sub chan<- streamer.SeedNodePayload, quitChan chan<- bool, streamFilters config.Subscription) Subscribe(id rpc.ID, sub chan<- streamer.SeedNodePayload, quitChan chan<- bool, streamFilters config.Subscription)
// Method to unsubscribe from state diff processing // Method to unsubscribe from state diff processing
Unsubscribe(id rpc.ID) Unsubscribe(id rpc.ID)
// Method to access the Geth node info for this service
Node() core.Node
} }
// Service is the underlying struct for the SyncAndPublish interface // Service is the underlying struct for the SyncAndPublish interface
@ -84,10 +86,12 @@ type Service struct {
SubscriptionTypes map[common.Hash]config.Subscription SubscriptionTypes map[common.Hash]config.Subscription
// Number of workers // Number of workers
WorkerPoolSize int WorkerPoolSize int
// Info for the Geth node that this seed node is working with
gethNode core.Node
} }
// NewSeedNode creates a new seed_node.Interface using an underlying seed_node.Service struct // NewSeedNode creates a new seed_node.Interface using an underlying seed_node.Service struct
func NewSeedNode(ipfsPath string, db *postgres.DB, rpcClient core.RpcClient, qc chan bool, workers int) (NodeInterface, error) { func NewSeedNode(ipfsPath string, db *postgres.DB, rpcClient core.RpcClient, qc chan bool, workers int, node core.Node) (NodeInterface, error) {
publisher, err := ipfs.NewIPLDPublisher(ipfsPath) publisher, err := ipfs.NewIPLDPublisher(ipfsPath)
if err != nil { if err != nil {
return nil, err return nil, err
@ -110,6 +114,7 @@ func NewSeedNode(ipfsPath string, db *postgres.DB, rpcClient core.RpcClient, qc
Subscriptions: make(map[common.Hash]map[rpc.ID]Subscription), Subscriptions: make(map[common.Hash]map[rpc.ID]Subscription),
SubscriptionTypes: make(map[common.Hash]config.Subscription), SubscriptionTypes: make(map[common.Hash]config.Subscription),
WorkerPoolSize: workers, WorkerPoolSize: workers,
gethNode: node,
}, nil }, nil
} }
@ -394,6 +399,11 @@ func (sap *Service) Stop() error {
return nil return nil
} }
// Node returns the Geth node info for this service
func (sap *Service) Node() core.Node {
return sap.gethNode
}
// close is used to close all listening subscriptions // close is used to close all listening subscriptions
func (sap *Service) close() { func (sap *Service) close() {
sap.Lock() sap.Lock()