Skip to content

Commit ec6b6f4

Browse files
committed
go: Avoid coupling of registration and beacon worker
1 parent 9d681b3 commit ec6b6f4

3 files changed

Lines changed: 9 additions & 14 deletions

File tree

go/oasis-node/cmd/node/node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ func (n *Node) initRuntimeWorkers(genesisDoc *genesisAPI.Document) error {
259259
n.BeaconWorker, err = workerBeacon.New(
260260
n.Identity,
261261
n.Consensus,
262-
n.RegistrationWorker,
262+
n.EntityID != nil,
263263
)
264264
if err != nil {
265265
return err

go/worker/beacon/worker.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/oasisprotocol/oasis-core/go/common/identity"
1010
"github.com/oasisprotocol/oasis-core/go/common/logging"
1111
consensus "github.com/oasisprotocol/oasis-core/go/consensus/api"
12-
"github.com/oasisprotocol/oasis-core/go/worker/registration"
1312
)
1413

1514
const workerName = "worker/beacon"
@@ -60,7 +59,7 @@ func (w *Worker) Name() string {
6059
func New(
6160
identity *identity.Identity,
6261
consensus consensus.Service,
63-
registrationWorker *registration.Worker,
62+
enabled bool,
6463
) (*Worker, error) {
6564
var (
6665
err error
@@ -74,9 +73,8 @@ func New(
7473
}
7574

7675
initLogger := logging.GetLogger(workerName)
77-
if registrationWorker.WillNeverRegister() {
78-
// Some node configurations never register, and that's ok.
79-
initLogger.Info("registration worker disabled, also disabling beacon worker")
76+
if !enabled {
77+
initLogger.Info("beacon worker disabled")
8078
close(w.allQuitCh)
8179
return w, nil
8280
}

go/worker/registration/worker.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,12 +1000,9 @@ func (w *Worker) RequestDeregistration() error {
10001000
return nil
10011001
}
10021002

1003-
// WillNeverRegister returns true iff the worker will never register.
1004-
func (w *Worker) WillNeverRegister() bool {
1005-
return !w.enabled
1006-
}
1007-
10081003
// New constructs a new worker node registration service.
1004+
//
1005+
// Entity ID is optional. If not provided this will be a no-op worker.
10091006
func New(
10101007
beacon beacon.Backend,
10111008
registry registry.Backend,
@@ -1078,9 +1075,9 @@ func (w *Worker) Name() string {
10781075
func (w *Worker) Start() error {
10791076
w.logger.Info("starting node registration service")
10801077

1081-
// HACK: This can be ok in certain configurations.
1082-
if w.WillNeverRegister() {
1083-
w.logger.Warn("no entity ID configured for this node, registration will NEVER succeed")
1078+
// TODO: stop abusing no-op workers. Instead worker should never be started
1079+
// if configuration says so.
1080+
if !w.enabled {
10841081
// Make sure the node is stopped on quit and that it can still respond to
10851082
// shutdown requests from the control api.
10861083
go func() {

0 commit comments

Comments
 (0)