The core protocol of WoopChain
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
woop/api/service/consensus/service.go

37 lines
945 B

6 years ago
package consensus
import (
msg_pb "github.com/harmony-one/harmony/api/proto/message"
6 years ago
"github.com/harmony-one/harmony/consensus"
"github.com/harmony-one/harmony/internal/utils"
)
// Service is the consensus service.
type Service struct {
consensus *consensus.Consensus
stopChan chan struct{}
messageChan chan *msg_pb.Message
6 years ago
}
// New returns consensus service.
func New(consensus *consensus.Consensus) *Service {
return &Service{consensus: consensus}
6 years ago
}
// Start starts consensus service.
func (s *Service) Start() error {
utils.Logger().Info().Msg("[consensus/service] Starting consensus service.")
6 years ago
s.stopChan = make(chan struct{})
s.consensus.Start(s.stopChan)
s.consensus.WaitForNewRandomness()
return nil
6 years ago
}
// Stop stops consensus service.
func (s *Service) Stop() error {
utils.Logger().Info().Msg("Stopping consensus service.")
close(s.stopChan)
utils.Logger().Info().Msg("Consensus service stopped.")
2 years ago
return nil
}