adding explorer service

pull/164/head
Minh Doan 6 years ago committed by Minh Doan
parent 89d5eabfa6
commit d148305843
  1. 1
      benchmark.go
  2. 12
      node/node.go
  3. 6
      services/explorer/service.go
  4. 2
      services/explorer/test2/main.go

@ -228,6 +228,7 @@ func main() {
go currentNode.SupportSyncing() go currentNode.SupportSyncing()
if consensus.IsLeader { if consensus.IsLeader {
go currentNode.SupportClient() go currentNode.SupportClient()
go currentNode.SupportExplorer()
} }
currentNode.StartServer() currentNode.StartServer()
} }

@ -15,6 +15,8 @@ import (
"sync/atomic" "sync/atomic"
"time" "time"
"github.com/harmony-one/harmony/services/explorer"
"github.com/harmony-one/harmony/client" "github.com/harmony-one/harmony/client"
clientService "github.com/harmony-one/harmony/client/service" clientService "github.com/harmony-one/harmony/client/service"
@ -494,6 +496,16 @@ func (node *Node) SupportClient() {
node.StartClientServer() node.StartClientServer()
} }
// SupportExplorer initializes and starts the client service
func (node *Node) SupportExplorer() {
es := explorer.Service{
IP: node.SelfPeer.IP,
Port: node.SelfPeer.Port,
}
es.Init(true)
es.Run()
}
// InitClientServer initializes client server. // InitClientServer initializes client server.
func (node *Node) InitClientServer() { func (node *Node) InitClientServer() {
node.clientServer = clientService.NewServer(node.Chain.State, node.CallFaucetContract) node.clientServer = clientService.NewServer(node.Chain.State, node.CallFaucetContract)

@ -17,7 +17,7 @@ import (
// Constants for explorer service. // Constants for explorer service.
const ( const (
ExplorerServicePort = "5000" ExplorerServicePort = "10000"
) )
// Service is the struct for explorer service. // Service is the struct for explorer service.
@ -29,8 +29,8 @@ type Service struct {
} }
// Init is to do init for ExplorerService. // Init is to do init for ExplorerService.
func (s *Service) Init() { func (s *Service) Init(remove bool) {
s.storage = GetStorageInstance(s.IP, s.Port, false) s.storage = GetStorageInstance(s.IP, s.Port, remove)
} }
// Run is to run serving explorer. // Run is to run serving explorer.

@ -7,6 +7,6 @@ func main() {
IP: "127.0.0.1", IP: "127.0.0.1",
Port: "9000", Port: "9000",
} }
service.Init() service.Init(false)
service.Run() service.Run()
} }

Loading…
Cancel
Save