Change get_election to use find_one.

This commit is contained in:
Lev Berman 2018-09-20 15:41:54 +02:00
parent b8113f3e7a
commit 8211fa916e

View File

@ -322,14 +322,12 @@ def get_validator_set(conn, height=None):
def get_election(conn, election_id):
query = {'election_id': election_id}
cursor = conn.run(
return conn.run(
conn.collection('elections')
.find(query, projection={'_id': False})
.sort([('height', DESCENDING)])
.find_one(query, projection={'_id': False},
sort=[('height', DESCENDING)])
)
return next(cursor, None)
@register_query(LocalMongoDBConnection)
def get_asset_tokens_for_public_key(conn, asset_id, public_key):