fix comments

pull/393/head
Minh Doan 6 years ago committed by Minh Doan
parent a962c28ec0
commit 51f7cf37e4
  1. 14
      api/service/blockproposal/service.go
  2. 2
      api/service/clientsupport/service.go
  3. 4
      api/service/consensus/service.go
  4. 18
      api/service/networkinfo/service.go
  5. 18
      api/service/staking/service.go

@ -4,7 +4,7 @@ import (
"github.com/harmony-one/harmony/internal/utils"
)
// Service is the new block service.
// Service is a block proposal service.
type Service struct {
stopChan chan struct{}
stoppedChan chan struct{}
@ -12,12 +12,12 @@ type Service struct {
waitForConsensusReady func(readySignal chan struct{}, stopChan chan struct{}, stoppedChan chan struct{})
}
// New returns new block service.
// New returns a block proposal service.
func New(readySignal chan struct{}, waitForConsensusReady func(readySignal chan struct{}, stopChan chan struct{}, stoppedChan chan struct{})) *Service {
return &Service{readySignal: readySignal, waitForConsensusReady: waitForConsensusReady}
}
// StartService starts new block service.
// StartService starts block proposal service.
func (s *Service) StartService() {
s.stopChan = make(chan struct{})
s.stoppedChan = make(chan struct{})
@ -26,18 +26,18 @@ func (s *Service) StartService() {
s.Run(s.stopChan, s.stoppedChan)
}
// Init initializes new block service.
// Init initializes block proposal service.
func (s *Service) Init() {
}
// Run runs new block.
// Run runs block proposal.
func (s *Service) Run(stopChan chan struct{}, stoppedChan chan struct{}) {
s.waitForConsensusReady(s.readySignal, s.stopChan, s.stoppedChan)
}
// StopService stops new block service.
// StopService stops block proposal service.
func (s *Service) StopService() {
utils.GetLogInstance().Info("Stopping new block service.")
utils.GetLogInstance().Info("Stopping block proposal service.")
s.stopChan <- struct{}{}
<-s.stoppedChan
utils.GetLogInstance().Info("Role conversion stopped.")

@ -14,7 +14,7 @@ const (
ClientServicePortDiff = 5555
)
// Service ...
// Service is the client support service.
type Service struct {
server *clientService.Server
grpcServer *grpc.Server

@ -19,14 +19,14 @@ func New(blockChannel chan *types.Block, consensus *consensus.Consensus) *Servic
return &Service{blockChannel: blockChannel, consensus: consensus}
}
// StartService starts service.
// StartService starts consensus service.
func (s *Service) StartService() {
s.stopChan = make(chan struct{})
s.stoppedChan = make(chan struct{})
s.consensus.WaitForNewBlock(s.blockChannel, s.stopChan, s.stoppedChan)
}
// StopService stops service.
// StopService stops consensus service.
func (s *Service) StopService() {
utils.GetLogInstance().Info("Stopping consensus service.")
s.stopChan <- struct{}{}

@ -5,14 +5,14 @@ import (
"github.com/harmony-one/harmony/p2p"
)
// Service is the role conversion service.
// Service is the network info service.
type Service struct {
stopChan chan struct{}
stoppedChan chan struct{}
peerChan chan *p2p.Peer
}
// New returns role conversion service.
// New returns network info service.
func New(peerChan chan *p2p.Peer) *Service {
return &Service{
stopChan: make(chan struct{}),
@ -21,24 +21,24 @@ func New(peerChan chan *p2p.Peer) *Service {
}
}
// StartService starts role conversion service.
// StartService starts network info service.
func (s *Service) StartService() {
s.Init()
s.Run()
}
// Init initializes role conversion service.
// Init initializes network info service.
func (s *Service) Init() {
}
// Run runs role conversion.
// Run runs network info.
func (s *Service) Run() {
go func() {
defer close(s.stoppedChan)
for {
select {
default:
utils.GetLogInstance().Info("Running role conversion")
utils.GetLogInstance().Info("Running network info")
// TODO: Write some logic here.
s.DoService()
case <-s.stopChan:
@ -48,15 +48,15 @@ func (s *Service) Run() {
}()
}
// DoService does role conversion.
// DoService does network info.
func (s *Service) DoService() {
// At the end, send Peer info to peer channel
s.peerChan <- &p2p.Peer{}
}
// StopService stops role conversion service.
// StopService stops network info service.
func (s *Service) StopService() {
utils.GetLogInstance().Info("Stopping role conversion service.")
utils.GetLogInstance().Info("Stopping network info service.")
s.stopChan <- struct{}{}
<-s.stoppedChan
utils.GetLogInstance().Info("Role conversion stopped.")

@ -5,14 +5,14 @@ import (
"github.com/harmony-one/harmony/p2p"
)
// Service is the role conversion service.
// Service is the staking service.
type Service struct {
stopChan chan struct{}
stoppedChan chan struct{}
peerChan chan *p2p.Peer
}
// New returns role conversion service.
// New returns staking service.
func New(peerChan chan *p2p.Peer) *Service {
return &Service{
stopChan: make(chan struct{}),
@ -21,17 +21,17 @@ func New(peerChan chan *p2p.Peer) *Service {
}
}
// StartService starts role conversion service.
// StartService starts staking service.
func (s *Service) StartService() {
s.Init()
s.Run()
}
// Init initializes role conversion service.
// Init initializes staking service.
func (s *Service) Init() {
}
// Run runs role conversion.
// Run runs staking.
func (s *Service) Run() {
// Wait until peer info of beacon chain is ready.
peer := <-s.peerChan
@ -40,7 +40,7 @@ func (s *Service) Run() {
for {
select {
default:
utils.GetLogInstance().Info("Running role conversion")
utils.GetLogInstance().Info("Running staking")
// TODO: Write some logic here.
s.DoService(peer)
case <-s.stopChan:
@ -50,13 +50,13 @@ func (s *Service) Run() {
}()
}
// DoService does role conversion.
// DoService does staking.
func (s *Service) DoService(peer *p2p.Peer) {
}
// StopService stops role conversion service.
// StopService stops staking service.
func (s *Service) StopService() {
utils.GetLogInstance().Info("Stopping role conversion service.")
utils.GetLogInstance().Info("Stopping staking service.")
s.stopChan <- struct{}{}
<-s.stoppedChan
utils.GetLogInstance().Info("Role conversion stopped.")

Loading…
Cancel
Save