mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Added an abstract base class so plugins don't need to add stubs for functions they don't care about.
This commit is contained in:
parent
ee4720d1a5
commit
380482b967
@ -0,0 +1,43 @@
|
||||
# TODO: no real reason to use abc yet, but later we can enforce inheritance from
|
||||
# this class when loading plugins if that's desirable.
|
||||
# from abc import ABCMeta
|
||||
|
||||
class AbstractConsensusRules:
|
||||
|
||||
# TODO: rather than having plugin-authors inherit and override,
|
||||
# it'd be cleaner to make a `transactionrule` decorator and etc
|
||||
@classmethod
|
||||
def validate_transaction(cls, bigchain, transaction):
|
||||
"""Validate a transaction.
|
||||
|
||||
Args:
|
||||
bigchain (Bigchain): an instantiated bigchaindb.Bigchain object.
|
||||
transaction (dict): transaction to validate.
|
||||
|
||||
Returns:
|
||||
The transaction if the transaction is valid else it raises an
|
||||
exception describing the reason why the transaction is invalid.
|
||||
|
||||
Raises:
|
||||
Descriptive exceptions indicating the reason the transaction failed.
|
||||
See the `exceptions` module for bigchain-native error classes.
|
||||
"""
|
||||
return transaction
|
||||
|
||||
@classmethod
|
||||
def validate_block(cls, bigchain, block):
|
||||
"""Validate a block.
|
||||
|
||||
Args:
|
||||
bigchain (Bigchain): an instantiated bigchaindb.Bigchain object.
|
||||
block (dict): block to validate.
|
||||
|
||||
Returns:
|
||||
The block if the block is valid else it raises and exception
|
||||
describing the reason why the block is invalid.
|
||||
|
||||
Raises:
|
||||
Descriptive exceptions indicating the reason the block failed.
|
||||
See the `exceptions` module for bigchain-native error classes.
|
||||
"""
|
||||
return block
|
@ -1,7 +1,8 @@
|
||||
import bigchaindb.exceptions as exceptions
|
||||
from bigchaindb.crypto import hash_data
|
||||
from bigchaindb.consensus import AbstractConsensusRules
|
||||
|
||||
class ConsensusRules(object):
|
||||
class ConsensusRules(AbstractConsensusRules):
|
||||
"""Base consensus rules for Bigchain.
|
||||
|
||||
This class can be copied to write your own consensus rules!
|
||||
|
Loading…
x
Reference in New Issue
Block a user