Skip to content
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

Merged
merged 9 commits into from
Oct 9, 2018

Conversation

jmatosp
Copy link
Contributor

@jmatosp jmatosp commented Oct 3, 2018

A short summary.

Important changes:

  • Something worth noting for reviewers.

Mandatory:

  • Added documentation.

Closes #

@jmatosp jmatosp added the WIP Work in progress label Oct 3, 2018
@jmatosp jmatosp requested a review from rgeraldes October 3, 2018 09:32
func (val *validator) notLoggedInState() stateFn {
chainHeadCh := make(chan core.ChainHeadEvent)
chainHeadSub := val.chain.SubscribeChainHeadEvent(chainHeadCh)
defer chainHeadSub.Unsubscribe()
Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

@jmatosp jmatosp removed the WIP Work in progress label Oct 8, 2018
@jmatosp
Copy link
Contributor Author

jmatosp commented Oct 8, 2018

@rgeraldes can you re-review

}

} else {
if val.isBlockZero() {
isVoter, err := val.consensus.IsValidator(val.walletAccount.Account().Address)
Copy link
Contributor

@rgeraldes rgeraldes Oct 8, 2018

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).

Copy link
Contributor Author

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?

Copy link
Contributor Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Copy link
Contributor

@rgeraldes rgeraldes left a 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.

@yourheropaul yourheropaul merged commit 6853ec6 into dev Oct 9, 2018
@yourheropaul yourheropaul deleted the feature/state-refactor branch October 9, 2018 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants