mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
better logging and arrangement for vote verification
This commit is contained in:
parent
c43bf10151
commit
ef5f3ddd28
@ -1,5 +1,11 @@
|
|||||||
|
import logging
|
||||||
|
|
||||||
from bigchaindb.util import verify_vote_signature
|
from bigchaindb.util import verify_vote_signature
|
||||||
from bigchaindb.common.schema import validate_vote_schema, SchemaValidationError
|
from bigchaindb.common.schema import SchemaValidationError, \
|
||||||
|
validate_vote_schema
|
||||||
|
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class BaseConsensusRules():
|
class BaseConsensusRules():
|
||||||
@ -26,10 +32,12 @@ class BaseConsensusRules():
|
|||||||
Refer to the documentation of
|
Refer to the documentation of
|
||||||
:func:`bigchaindb.util.verify_signature`.
|
:func:`bigchaindb.util.verify_signature`.
|
||||||
"""
|
"""
|
||||||
|
if verify_vote_signature(voters, signed_vote):
|
||||||
try:
|
try:
|
||||||
validate_vote_schema(signed_vote)
|
validate_vote_schema(signed_vote)
|
||||||
except SchemaValidationError:
|
return True
|
||||||
# TODO: log this.
|
except SchemaValidationError as exc:
|
||||||
|
logger.warning(exc)
|
||||||
|
logger.warning("Vote failed signature verification: "
|
||||||
|
"%s with voters: %s", signed_vote, voters)
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
return verify_vote_signature(voters, signed_vote)
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user