network: extend Service with Name, use it to distinguish services

This commit is contained in:
Roman Khimov 2022-04-22 11:33:56 +03:00
parent a10b1ad32d
commit 2593bb0535
8 changed files with 41 additions and 10 deletions

View file

@ -63,6 +63,8 @@ type Ledger interface {
// Service represents consensus instance.
type Service interface {
// Name returns service name.
Name() string
// Start initializes dBFT and starts event loop for consensus service.
// It must be called only when sufficient amount of peers are connected.
Start()
@ -256,6 +258,11 @@ func (s *service) newPrepareRequest() payload.PrepareRequest {
return r
}
// Name returns service name.
func (s *service) Name() string {
return "consensus"
}
func (s *service) Start() {
if s.started.CAS(false, true) {
s.log.Info("starting consensus service")