|
@ -58,7 +58,6 @@ type nodeImpl struct { |
|
|
router *p2p.Router |
|
|
router *p2p.Router |
|
|
nodeInfo types.NodeInfo |
|
|
nodeInfo types.NodeInfo |
|
|
nodeKey types.NodeKey // our node privkey
|
|
|
nodeKey types.NodeKey // our node privkey
|
|
|
isListening bool |
|
|
|
|
|
|
|
|
|
|
|
// services
|
|
|
// services
|
|
|
eventSinks []indexer.EventSink |
|
|
eventSinks []indexer.EventSink |
|
@ -421,8 +420,6 @@ func makeNode( |
|
|
node.rpcEnv.PubKey = pubKey |
|
|
node.rpcEnv.PubKey = pubKey |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
node.rpcEnv.P2PTransport = node |
|
|
|
|
|
|
|
|
|
|
|
node.BaseService = *service.NewBaseService(logger, "Node", node) |
|
|
node.BaseService = *service.NewBaseService(logger, "Node", node) |
|
|
|
|
|
|
|
|
return node, nil |
|
|
return node, nil |
|
@ -467,6 +464,7 @@ func (n *nodeImpl) OnStart(ctx context.Context) error { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
n.rpcEnv.NodeInfo = n.nodeInfo |
|
|
// Start the RPC server before the P2P server
|
|
|
// Start the RPC server before the P2P server
|
|
|
// so we can eg. receive txs for the first block
|
|
|
// so we can eg. receive txs for the first block
|
|
|
if n.config.RPC.ListenAddress != "" { |
|
|
if n.config.RPC.ListenAddress != "" { |
|
@ -485,7 +483,7 @@ func (n *nodeImpl) OnStart(ctx context.Context) error { |
|
|
if err := n.router.Start(ctx); err != nil { |
|
|
if err := n.router.Start(ctx); err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
n.isListening = true |
|
|
|
|
|
|
|
|
n.rpcEnv.IsListening = true |
|
|
|
|
|
|
|
|
for _, reactor := range n.services { |
|
|
for _, reactor := range n.services { |
|
|
if err := reactor.Start(ctx); err != nil { |
|
|
if err := reactor.Start(ctx); err != nil { |
|
@ -580,7 +578,7 @@ func (n *nodeImpl) OnStop() { |
|
|
|
|
|
|
|
|
n.stateSyncReactor.Wait() |
|
|
n.stateSyncReactor.Wait() |
|
|
n.router.Wait() |
|
|
n.router.Wait() |
|
|
n.isListening = false |
|
|
|
|
|
|
|
|
n.rpcEnv.IsListening = false |
|
|
|
|
|
|
|
|
// finally stop the listeners / external services
|
|
|
// finally stop the listeners / external services
|
|
|
for _, l := range n.rpcListeners { |
|
|
for _, l := range n.rpcListeners { |
|
@ -669,21 +667,6 @@ func (n *nodeImpl) RPCEnvironment() *rpccore.Environment { |
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
func (n *nodeImpl) Listeners() []string { |
|
|
|
|
|
return []string{ |
|
|
|
|
|
fmt.Sprintf("Listener(@%v)", n.config.P2P.ExternalAddress), |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (n *nodeImpl) IsListening() bool { |
|
|
|
|
|
return n.isListening |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// NodeInfo returns the Node's Info from the Switch.
|
|
|
|
|
|
func (n *nodeImpl) NodeInfo() types.NodeInfo { |
|
|
|
|
|
return n.nodeInfo |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// genesisDocProvider returns a GenesisDoc.
|
|
|
// genesisDocProvider returns a GenesisDoc.
|
|
|
// It allows the GenesisDoc to be pulled from sources other than the
|
|
|
// It allows the GenesisDoc to be pulled from sources other than the
|
|
|
// filesystem, for instance from a distributed key-value store cluster.
|
|
|
// filesystem, for instance from a distributed key-value store cluster.
|
|
|