Problem: Invalid/redundant methods in side ValidatorElection

Solution: Override methods and raise execptions for code clarity
This commit is contained in:
Vanshdeep Singh 2018-07-25 16:51:37 +02:00
parent 04d9aeeab1
commit f8e0deee12
2 changed files with 14 additions and 4 deletions

View File

@ -1236,7 +1236,9 @@ class Transaction(object):
def resolve_class(operation): def resolve_class(operation):
"""For the given `tx` based on the `operation` key return its implementation class""" """For the given `tx` based on the `operation` key return its implementation class"""
if operation in list(Transaction.type_registry.keys()): create_txn_class = Transaction.type_registry.get(Transaction.CREATE)
return Transaction.type_registry.get(operation) return Transaction.type_registry.get(operation, create_txn_class)
else:
return Transaction.type_registry.get(Transaction.CREATE) @classmethod
def validate_schema(cls, tx):
pass

View File

@ -131,3 +131,11 @@ class ValidatorElection(Transaction):
_validate_schema(TX_SCHEMA_COMMON, tx) _validate_schema(TX_SCHEMA_COMMON, tx)
_validate_schema(TX_SCHEMA_CREATE, tx) _validate_schema(TX_SCHEMA_CREATE, tx)
_validate_schema(TX_SCHEMA_VALIDATOR_ELECTION, tx) _validate_schema(TX_SCHEMA_VALIDATOR_ELECTION, tx)
@classmethod
def create(cls, tx_signers, recipients, metadata=None, asset=None):
raise NotImplementedError
@classmethod
def transfer(cls, tx_signers, recipients, metadata=None, asset=None):
raise NotImplementedError