getter rpc method for the seed node's geth info
This commit is contained in:
parent
2c997921cb
commit
8fe273fb7b
@ -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)
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user