diff --git a/cmd/syncAndPublish.go b/cmd/syncAndPublish.go index aef33bd3..c6a36b25 100644 --- a/cmd/syncAndPublish.go +++ b/cmd/syncAndPublish.go @@ -73,7 +73,7 @@ func syncAndPublish() { if 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 { log.Fatal(err) } diff --git a/cmd/syncPublishScreenAndServe.go b/cmd/syncPublishScreenAndServe.go index 8e52647c..b0ef1ad7 100644 --- a/cmd/syncPublishScreenAndServe.go +++ b/cmd/syncPublishScreenAndServe.go @@ -67,7 +67,7 @@ func syncPublishScreenAndServe() { if 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 { log.Fatal(err) } diff --git a/pkg/seed_node/api.go b/pkg/seed_node/api.go index 0b17dfd9..623bcb9a 100644 --- a/pkg/seed_node/api.go +++ b/pkg/seed_node/api.go @@ -24,6 +24,7 @@ import ( "github.com/vulcanize/vulcanizedb/libraries/shared/streamer" "github.com/vulcanize/vulcanizedb/pkg/config" + "github.com/vulcanize/vulcanizedb/pkg/core" ) // 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 } + +// 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() +} diff --git a/pkg/seed_node/service.go b/pkg/seed_node/service.go index e8162ae3..4588f5be 100644 --- a/pkg/seed_node/service.go +++ b/pkg/seed_node/service.go @@ -52,6 +52,8 @@ type NodeInterface interface { Subscribe(id rpc.ID, sub chan<- streamer.SeedNodePayload, quitChan chan<- bool, streamFilters config.Subscription) // Method to unsubscribe from state diff processing 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 @@ -84,10 +86,12 @@ type Service struct { SubscriptionTypes map[common.Hash]config.Subscription // Number of workers 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 -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) if err != nil { 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), SubscriptionTypes: make(map[common.Hash]config.Subscription), WorkerPoolSize: workers, + gethNode: node, }, nil } @@ -394,6 +399,11 @@ func (sap *Service) Stop() error { 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 func (sap *Service) close() { sap.Lock()