mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Added some nonsense consensus rules to demonstrate a simpler plugin.
This commit is contained in:
parent
380482b967
commit
2c8cea11eb
21
bigchaindb/consensus/silly.py
Normal file
21
bigchaindb/consensus/silly.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import bigchaindb.exceptions as exceptions
|
||||||
|
from bigchaindb.crypto import hash_data
|
||||||
|
from bigchaindb.consensus import AbstractConsensusRules
|
||||||
|
|
||||||
|
|
||||||
|
class SillyConsensusRules(AbstractConsensusRules):
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def validate_transaction(cls, bigchain, transaction):
|
||||||
|
# I only like transactions whose timestamps are even.
|
||||||
|
if transaction['transaction']['timestamp'] % 2 != 0:
|
||||||
|
raise StandardError("Odd... very odd indeed.")
|
||||||
|
return transaction
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def validate_block(cls, bigchain, transaction):
|
||||||
|
# I don't trust Alice, I think she's shady.
|
||||||
|
if block['block']['node_pubkey'] == '<ALICE_PUBKEY>':
|
||||||
|
raise StandardError("Alice is shady, everybody ignore her blocks!")
|
||||||
|
|
||||||
|
return block
|
Loading…
x
Reference in New Issue
Block a user