mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: Election class variable to VOTE_TYPE unnecessary
Solution: Removed the variable and hardcoded everything to use the `Vote` class
This commit is contained in:
parent
fdacca7976
commit
2eb32d93f6
@ -24,8 +24,6 @@ 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,)
|
||||
OPERATION = None
|
||||
# the model for votes issued by the election
|
||||
VOTE_TYPE = Vote
|
||||
# Custom validation schema
|
||||
TX_SCHEMA_CUSTOM = None
|
||||
# Election Statuses:
|
||||
@ -166,7 +164,7 @@ class Election(Transaction):
|
||||
def count_votes(cls, election_pk, transactions, getter=getattr):
|
||||
votes = 0
|
||||
for txn in transactions:
|
||||
if getter(txn, 'operation') == cls.VOTE_TYPE.OPERATION:
|
||||
if getter(txn, 'operation') == Vote.OPERATION:
|
||||
for output in getter(txn, 'outputs'):
|
||||
# NOTE: We enforce that a valid vote to election id will have only
|
||||
# election_pk in the output public keys, including any other public key
|
||||
@ -232,7 +230,7 @@ class Election(Transaction):
|
||||
def approved_update(cls, bigchain, new_height, txns):
|
||||
votes = {}
|
||||
for txn in txns:
|
||||
if not isinstance(txn, cls.VOTE_TYPE):
|
||||
if not isinstance(txn, Vote):
|
||||
continue
|
||||
|
||||
election_id = txn.asset['id']
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user