go/worker/registration: Clean dead registration signer code#6481
go/worker/registration: Clean dead registration signer code#6481martintomazic merged 6 commits intomasterfrom
Conversation
✅ Deploy Preview for oasisprotocol-oasis-core canceled.
|
f596604 to
825920c
Compare
825920c to
e001aff
Compare
f37acc8 to
7e2a103
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6481 +/- ##
==========================================
- Coverage 64.45% 64.01% -0.44%
==========================================
Files 699 698 -1
Lines 68216 68195 -21
==========================================
- Hits 43966 43653 -313
- Misses 19187 19521 +334
+ Partials 5063 5021 -42 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
7e2a103 to
836120b
Compare
| w.storedDeregister = storedDeregister | ||
|
|
||
| // If node has no entity it will not register. | ||
| if entityID != nil { |
There was a problem hiding this comment.
This is not the best, as looking at the constructor signature one has no idea that this can be nil. Can we add another commit and fix TODO below (stop abusing no-op workers)?
There was a problem hiding this comment.
This is not the best, as looking at the constructor signature one has no idea that this can be nil
Go type system is explicit. The current constructor signature means: entity id may be nil or have value of type public key. Pointer types are not so nice workaround for the missing option type in go. You use them to avoid copying huge values, have a shared reference, or mimic optional type.
What is not best is to assume that a pointer is not nil unless documented explicitly. We do this too often, with immutable small structs (smell), that should not be passed as pointers in the first place.
I agree this is still ugly, thus I have added an explicit comment. Clean way is to get rid of no-op workers but this is not trivial.
836120b to
68056b2
Compare
This is needed for introducing explicit configuration modes, e.g. new observer mode and failing early in case of missing entityID. It also removes global state from the registration worker.
68056b2 to
573fb3c
Compare
Motivation: Simplify #6474 (comment).