Skip to content

Generalize election management commands#2515

Merged
kansi merged 32 commits intobigchaindb:masterfrom
z-bowen:generalize-election-management-commands
Sep 12, 2018
Merged

Generalize election management commands#2515
kansi merged 32 commits intobigchaindb:masterfrom
z-bowen:generalize-election-management-commands

Conversation

@z-bowen
Copy link
Copy Markdown
Contributor

@z-bowen z-bowen commented Sep 5, 2018

Problem: CLI methods for election management need to be generalized away from upsert-validator

Solution

Rework the CLI methods to work with the more general Election base class

z-bowen added 18 commits August 31, 2018 10:31
…from a common `Election` class

Solution: Factored the common logic out of `ValidatorElection` and moved it to `Election` parent class
Solution: Refactored `get_result_by_election_id` to `get_election_result_by_id`
…ables

Solution: Remove `DB_TABLE` property from `Election` class
… 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
@z-bowen z-bowen requested review from kansi and ldmberman September 5, 2018 11:30
@codecov-io
Copy link
Copy Markdown

codecov-io commented Sep 5, 2018

Codecov Report

Merging #2515 into master will decrease coverage by 0.01%.
The diff coverage is 93.75%.

@@            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
help='Calls a new election.')
# parser for managing elections
election_parser = subparsers.add_parser('election',
help='Add/update/delete a validator.')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The help message needs an update.


###### election new upsert-validator

Call an election to add/update/remove a validator from the validator set.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Call Create/Generate

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

#### 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can approved by ... -> can be approved by ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

# 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']
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

help is a reserved keyword - I would just .add_parser(name, data['help']).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Solution: Removed the variable, as we didn't really need it anyway
## 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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The specific for general election are described in BEP-18 and not BEP-21

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed

Solution: Pointed them to BEP-18 instead of BEP-21
@kansi kansi merged commit 8a7650c into bigchaindb:master Sep 12, 2018
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.

4 participants