mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Problem: the skip_id param is redundant. (#2531)
Solution: remove the param; only call validate_id where it is needed.
This commit is contained in:
parent
6a9064196a
commit
f55f22144f
@ -1195,7 +1195,9 @@ class Transaction(object):
|
||||
"""
|
||||
operation = tx.get('operation', Transaction.CREATE) if isinstance(tx, dict) else Transaction.CREATE
|
||||
cls = Transaction.resolve_class(operation)
|
||||
|
||||
if not skip_schema_validation:
|
||||
cls.validate_id(tx)
|
||||
cls.validate_schema(tx)
|
||||
|
||||
inputs = [Input.from_dict(input_) for input_ in tx['inputs']]
|
||||
|
@ -42,16 +42,14 @@ class Vote(Transaction):
|
||||
def generate(cls, inputs, recipients, election_id, metadata=None):
|
||||
(inputs, outputs) = cls.validate_transfer(inputs, recipients, election_id, metadata)
|
||||
election_vote = cls(cls.OPERATION, {'id': election_id}, inputs, outputs, metadata)
|
||||
cls.validate_schema(election_vote.to_dict(), skip_id=True)
|
||||
cls.validate_schema(election_vote.to_dict())
|
||||
return election_vote
|
||||
|
||||
@classmethod
|
||||
def validate_schema(cls, tx, skip_id=False):
|
||||
def validate_schema(cls, tx):
|
||||
"""Validate the validator election vote transaction. Since `VOTE` extends `TRANSFER`
|
||||
transaction, all the validations for `CREATE` transaction should be inherited
|
||||
"""
|
||||
if not skip_id:
|
||||
cls.validate_id(tx)
|
||||
_validate_schema(TX_SCHEMA_COMMON, tx)
|
||||
_validate_schema(TX_SCHEMA_TRANSFER, tx)
|
||||
_validate_schema(cls.TX_SCHEMA_CUSTOM, tx)
|
||||
|
@ -45,7 +45,6 @@ class Transaction(Transaction):
|
||||
|
||||
@classmethod
|
||||
def validate_schema(cls, tx_body):
|
||||
cls.validate_id(tx_body)
|
||||
validate_transaction_schema(tx_body)
|
||||
validate_txn_obj('asset', tx_body['asset'], 'data', validate_key)
|
||||
validate_txn_obj('metadata', tx_body, 'metadata', validate_key)
|
||||
|
Loading…
x
Reference in New Issue
Block a user