Problem: No good way to check for val set absence.

Solution: Make get_validator_set/get_validators return None/[] when there are no validators yet.
This commit is contained in:
Lev Berman 2018-08-29 12:37:08 +02:00
parent fe0a4c494b
commit d0a7df8d17
2 changed files with 2 additions and 3 deletions

View File

@ -296,7 +296,7 @@ def get_validator_set(conn, height=None):
.limit(1)
)
return list(cursor)[0]
return next(cursor, None)
@register_query(LocalMongoDBConnection)

View File

@ -426,8 +426,7 @@ class BigchainDB(object):
def get_validators(self, height=None):
result = self.get_validator_change(height)
validators = result['validators']
return validators
return [] if result is None else result['validators']
def get_validators_by_election_id(self, election_id):
result = backend.query.get_validator_set_by_election_id(self.connection, election_id)