mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
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:
parent
fe0a4c494b
commit
d0a7df8d17
@ -296,7 +296,7 @@ def get_validator_set(conn, height=None):
|
|||||||
.limit(1)
|
.limit(1)
|
||||||
)
|
)
|
||||||
|
|
||||||
return list(cursor)[0]
|
return next(cursor, None)
|
||||||
|
|
||||||
|
|
||||||
@register_query(LocalMongoDBConnection)
|
@register_query(LocalMongoDBConnection)
|
||||||
|
|||||||
@ -426,8 +426,7 @@ class BigchainDB(object):
|
|||||||
|
|
||||||
def get_validators(self, height=None):
|
def get_validators(self, height=None):
|
||||||
result = self.get_validator_change(height)
|
result = self.get_validator_change(height)
|
||||||
validators = result['validators']
|
return [] if result is None else result['validators']
|
||||||
return validators
|
|
||||||
|
|
||||||
def get_validators_by_election_id(self, election_id):
|
def get_validators_by_election_id(self, election_id):
|
||||||
result = backend.query.get_validator_set_by_election_id(self.connection, election_id)
|
result = backend.query.get_validator_set_by_election_id(self.connection, election_id)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user