Generalize election management commands#2515
Merged
kansi merged 32 commits intobigchaindb:masterfrom Sep 12, 2018
Merged
Conversation
…from a common `Election` class Solution: Factored the common logic out of `ValidatorElection` and moved it to `Election` parent class
Solution: Reverting the changes
Solution: Refactored `get_result_by_election_id` to `get_election_result_by_id`
…ables Solution: Remove `DB_TABLE` property from `Election` class
…ir own tables" This reverts commit db45374.
… for an election method Solution: Finished the refactoring
Solution: Created the `elections` table with secondary_index `election_id`
…tions in the `elections` table Solution: Updated the class to use the new table
Solution: Renamed, refactored and moved the `Vote` class to tie in with the more general `Election` base class
Solution: Fixed the docstring
Solution: Pointed the reference to the class variable
…ote` Solution: Renamed `TX_SCHEMA_VALIDATOR_ELECTION_VOTE` as `TX_SCHEMA_VOTE`
Solution: Renamed `ELECTION_TYPE` to `OPERATION`
…ed to manage any type of election Solution: Refactored the CLI to manage generalized elections
Codecov Report
@@ Coverage Diff @@
## master #2515 +/- ##
==========================================
- Coverage 93.37% 93.36% -0.02%
==========================================
Files 43 44 +1
Lines 2583 2594 +11
==========================================
+ Hits 2412 2422 +10
- Misses 171 172 +1 |
…lass Solution: Create a default method that work if all fields in the 'asset[data]' can be displayed without additional formatting
Solution: Addressed comments from PR
Solution: Removed the variable and hardcoded everything to use the `Vote` class
Solution: Addressing comments
Solution: Aligned the tests to reflect the changed key format
ldmberman
reviewed
Sep 10, 2018
bigchaindb/commands/bigchaindb.py
Outdated
| help='Calls a new election.') | ||
| # parser for managing elections | ||
| election_parser = subparsers.add_parser('election', | ||
| help='Add/update/delete a validator.') |
Contributor
There was a problem hiding this comment.
The help message needs an update.
Solution: Cast any public key to base64
Solution: Updated the help message
kansi
reviewed
Sep 12, 2018
|
|
||
| ###### election new upsert-validator | ||
|
|
||
| Call an election to add/update/remove a validator from the validator set. |
kansi
reviewed
Sep 12, 2018
| #### upsert-validator approve | ||
| #### election approve | ||
|
|
||
| Approve an election by voting for it. The propsal generated by executing `bigchaindb election new ...` can approved by the validators using this command. The validator who is approving the proposal will spend all their votes i.e. if the validator has a network power of `10` then they will cast `10` votes for the proposal. |
Contributor
There was a problem hiding this comment.
can approved by ... -> can be approved by ...
Solution: Fixed the typos
kansi
reviewed
Sep 12, 2018
ldmberman
reviewed
Sep 12, 2018
ldmberman
reviewed
Sep 12, 2018
bigchaindb/commands/bigchaindb.py
Outdated
| # Parser factory for each type of new election, so we get a bunch of commands that look like this: | ||
| # election new <some_election_type> <args>... | ||
| for name, data in elections.items(): | ||
| help = data['help'] |
Contributor
There was a problem hiding this comment.
help is a reserved keyword - I would just .add_parser(name, data['help']).
ldmberman
approved these changes
Sep 12, 2018
Solution: Removed the variable, as we didn't really need it anyway
kansi
reviewed
Sep 12, 2018
| ## bigchaindb election | ||
|
|
||
| Manage elections to add, update, or remove a validator from the validators set. The upsert-validator subcommands implement [BEP-21](https://github.com/bigchaindb/BEPs/tree/master/21), please refer it for more details. | ||
| Manage elections to manage the BigChainDB network. The specifics of the election process are defined in [BEP-21](https://github.com/bigchaindb/BEPs/tree/master/21), please refer it for more details. |
Contributor
There was a problem hiding this comment.
The specific for general election are described in BEP-18 and not BEP-21
Solution: Pointed them to BEP-18 instead of BEP-21
kansi
approved these changes
Sep 12, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: CLI methods for election management need to be generalized away from
upsert-validatorSolution
Rework the CLI methods to work with the more general
Electionbase class