Pipelines¶
Block Creation¶
This module takes care of all the logic related to block creation.
The logic is encapsulated in the BlockPipeline
class, while the sequence
of actions to do on transactions is specified in the create_pipeline
function.
-
class
bigchaindb.pipelines.block.
BlockPipeline
[source]¶ This class encapsulates the logic to create blocks.
Note
Methods of this class will be executed in different processes.
-
filter_tx
(tx)[source]¶ Filter a transaction.
Parameters: tx (dict) – the transaction to process. Returns: The transaction if assigned to the current node, None
otherwise.Return type: dict
-
validate_tx
(tx)[source]¶ Validate a transaction.
Also checks if the transaction already exists in the blockchain. If it does, or it’s invalid, it’s deleted from the backlog immediately.
Parameters: tx (dict) – the transaction to validate. Returns: The transaction if valid, None
otherwise.Return type: Transaction
-
create
(tx, timeout=False)[source]¶ Create a block.
This method accumulates transactions to put in a block and outputs a block when one of the following conditions is true: - the size limit of the block has been reached, or - a timeout happened.
Parameters: - tx (
Transaction
) – the transaction to validate, might be None if a timeout happens. - timeout (bool) –
True
if a timeout happened (Default:False
).
Returns: The block, if a block is ready, or
None
.Return type: Block
- tx (
-
Block Voting¶
This module takes care of all the logic related to block voting.
The logic is encapsulated in the Vote
class, while the sequence
of actions to do on transactions is specified in the create_pipeline
function.
-
class
bigchaindb.pipelines.vote.
Vote
[source]¶ This class encapsulates the logic to vote on blocks.
Note
Methods of this class will be executed in different processes.
-
ungroup
(block_id, transactions)[source]¶ Given a block, ungroup the transactions in it.
Parameters: Returns: None
if the block has been already voted, an iterator that yields a transaction, block id, and the total number of transactions contained in the block otherwise.
-
validate_tx
(tx_dict, block_id, num_tx)[source]¶ - Validate a transaction. Transaction must also not be in any VALID
- block.
Parameters: Returns: Three values are returned, the validity of the transaction,
block_id
,num_tx
.
-
-
bigchaindb.pipelines.vote.
create_pipeline
()[source]¶ Create and return the pipeline of operations to be distributed on different processes.
Block Status¶
This module takes care of all the logic related to block status.
Specifically, what happens when a block becomes invalid. The logic is
encapsulated in the Election
class, while the sequence of actions
is specified in create_pipeline
.
Stale Transaction Monitoring¶
This module monitors for stale transactions.
It reassigns transactions which have been assigned a node but remain in the backlog past a certain amount of time.
-
class
bigchaindb.pipelines.stale.
StaleTransactionMonitor
(timeout=5, backlog_reassign_delay=None)[source]¶ This class encapsulates the logic for re-assigning stale transactions.
Note
Methods of this class will be executed in different processes.