From 0c64fbfb5df429ea204bdb367437cda83d49b2a1 Mon Sep 17 00:00:00 2001 From: z-bowen Date: Wed, 5 Sep 2018 10:41:05 +0200 Subject: [PATCH] Problem: `Election` class variable `ELECTION_TYPE` is overly specific Solution: Renamed `ELECTION_TYPE` to `OPERATION` --- bigchaindb/__init__.py | 2 +- bigchaindb/common/election.py | 4 ++-- bigchaindb/upsert_validator/validator_election.py | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bigchaindb/__init__.py b/bigchaindb/__init__.py index b63afa3d..2e4ef8b5 100644 --- a/bigchaindb/__init__.py +++ b/bigchaindb/__init__.py @@ -98,5 +98,5 @@ from bigchaindb.common.vote import Vote # noqa Transaction.register_type(Transaction.CREATE, models.Transaction) Transaction.register_type(Transaction.TRANSFER, models.Transaction) -Transaction.register_type(ValidatorElection.ELECTION_TYPE, ValidatorElection) +Transaction.register_type(ValidatorElection.OPERATION, ValidatorElection) Transaction.register_type(Vote.VOTE, Vote) diff --git a/bigchaindb/common/election.py b/bigchaindb/common/election.py index f43b743f..d9e907f9 100644 --- a/bigchaindb/common/election.py +++ b/bigchaindb/common/election.py @@ -23,7 +23,7 @@ class Election(Transaction): # NOTE: this transaction class extends create so the operation inheritance is achieved # by setting an ELECTION_TYPE and renaming CREATE = ELECTION_TYPE and ALLOWED_OPERATIONS = (ELECTION_TYPE,) - ELECTION_TYPE = None + OPERATION = None # the model for votes issued by the election VOTE_TYPE = Vote # Election Statuses: @@ -132,7 +132,7 @@ class Election(Transaction): @classmethod def generate(cls, initiator, voters, election_data, metadata=None): (inputs, outputs) = cls.validate_create(initiator, voters, election_data, metadata) - election = cls(cls.ELECTION_TYPE, {'data': election_data}, inputs, outputs, metadata) + election = cls(cls.OPERATION, {'data': election_data}, inputs, outputs, metadata) cls.validate_schema(election.to_dict(), skip_id=True) return election diff --git a/bigchaindb/upsert_validator/validator_election.py b/bigchaindb/upsert_validator/validator_election.py index 0b94c71e..97e7a1ab 100644 --- a/bigchaindb/upsert_validator/validator_election.py +++ b/bigchaindb/upsert_validator/validator_election.py @@ -11,11 +11,11 @@ from .validator_utils import (new_validator_set, encode_validator) class ValidatorElection(Election): - ELECTION_TYPE = 'VALIDATOR_ELECTION' + OPERATION = 'VALIDATOR_ELECTION' # NOTE: this transaction class extends create so the operation inheritence is achieved # by renaming CREATE to VALIDATOR_ELECTION - CREATE = ELECTION_TYPE - ALLOWED_OPERATIONS = (ELECTION_TYPE,) + CREATE = OPERATION + ALLOWED_OPERATIONS = (OPERATION,) def validate(self, bigchain, current_transactions=[]): """For more details refer BEP-21: https://github.com/bigchaindb/BEPs/tree/master/21