mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: Election class variable ELECTION_TYPE is overly specific
Solution: Renamed `ELECTION_TYPE` to `OPERATION`
This commit is contained in:
parent
331b52cc4c
commit
0c64fbfb5d
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user