-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactored not logged in state to smaller parts #804
Conversation
client/knode/validator/states.go
Outdated
func (val *validator) notLoggedInState() stateFn { | ||
chainHeadCh := make(chan core.ChainHeadEvent) | ||
chainHeadSub := val.chain.SubscribeChainHeadEvent(chainHeadCh) | ||
defer chainHeadSub.Unsubscribe() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rgeraldes can you explain what this is doing? this func only has a call so the defer unsubscribes right after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chainHeadSub lets us know when there's a new chain head (block) > check the state again to verify if the user is a validator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but chainHeadSub is not in use anywhere. And it's closes the channel as soon at exits that func
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's true - we can remove it for now.
@rgeraldes can you re-review |
client/knode/validator/states.go
Outdated
} | ||
|
||
} else { | ||
if val.isBlockZero() { | ||
isVoter, err := val.consensus.IsValidator(val.walletAccount.Account().Address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is not necessary as according to the contract, in order to be a genesis on block 0, the user needs to be registered as a validator. (Genesis flag is set during the registration process, there's no way around it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure what you mean with remove the check.
Does that means that a genesis validator never does a deposit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see, got the line worng, so as long is a genesis and block zero can just start validating imediatly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a small comment about a possible optimisation.
A short summary.
Important changes:
Mandatory:
Closes #