mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Revert "Problem: No need to store different types of elections in their own tables"
This reverts commit db45374d3c690429d18a25bcc319f8056c016500.
This commit is contained in:
parent
db45374d3c
commit
bd76b31e40
@ -300,11 +300,11 @@ def get_validator_set(conn, height=None):
|
||||
|
||||
|
||||
@register_query(LocalMongoDBConnection)
|
||||
def get_election_result_by_id(conn, election_id):
|
||||
def get_election_result_by_id(conn, election_id, table):
|
||||
query = {'election_id': election_id}
|
||||
|
||||
cursor = conn.run(
|
||||
conn.collection('validators')
|
||||
conn.collection(table)
|
||||
.find(query, projection={'_id': False})
|
||||
)
|
||||
|
||||
|
||||
@ -361,7 +361,7 @@ def get_validator_set(conn, height):
|
||||
|
||||
|
||||
@singledispatch
|
||||
def get_election_result_by_id(conn, election_id):
|
||||
def get_election_result_by_id(conn, election_id, table):
|
||||
"""Return a validator set change with the specified election_id
|
||||
"""
|
||||
|
||||
|
||||
@ -23,6 +23,8 @@ 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
|
||||
# the name of the mongodb table managed by the election
|
||||
DB_TABLE = None
|
||||
# the model for votes issued by the election
|
||||
VOTE_TYPE = None
|
||||
# Election Statuses:
|
||||
@ -219,7 +221,7 @@ class Election(Transaction):
|
||||
return self.ONGOING
|
||||
|
||||
def get_election_result(self, election_id, bigchain):
|
||||
result = bigchain.get_election_result_by_id(election_id)
|
||||
result = bigchain.get_election_result_by_id(election_id, self.DB_TABLE)
|
||||
return result
|
||||
|
||||
@classmethod
|
||||
|
||||
@ -429,8 +429,8 @@ class BigchainDB(object):
|
||||
validators = result['validators']
|
||||
return validators
|
||||
|
||||
def get_election_result_by_id(self, election_id):
|
||||
result = backend.query.get_election_result_by_id(self.connection, election_id)
|
||||
def get_result_by_election_id(self, election_id, table):
|
||||
result = backend.query.get_election_result_by_id(self.connection, election_id, table)
|
||||
return result
|
||||
|
||||
def store_pre_commit_state(self, state):
|
||||
|
||||
@ -17,6 +17,7 @@ class ValidatorElection(Election):
|
||||
# by renaming CREATE to VALIDATOR_ELECTION
|
||||
CREATE = ELECTION_TYPE
|
||||
ALLOWED_OPERATIONS = (ELECTION_TYPE,)
|
||||
DB_TABLE = 'validators'
|
||||
VOTE_TYPE = ValidatorElectionVote
|
||||
|
||||
def validate(self, bigchain, current_transactions=[]):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user