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 (
-
-
bigchaindb.pipelines.block.
get_changefeed
()[source]¶ Create and return the changefeed for the backlog.
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, block_id, num_tx)[source]¶ Validate a transaction.
Parameters: Returns: Three values are returned, the validity of the transaction,
block_id
,num_tx
.
-
-
bigchaindb.pipelines.vote.
get_changefeed
()[source]¶ Create and return the changefeed for the bigchain table.
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.
Utilities¶
Utility classes and functions to work with the pipelines.
-
class
bigchaindb.pipelines.utils.
ChangeFeed
(table, operation, prefeed=None, bigchain=None)[source]¶ This class wraps a RethinkDB changefeed adding a
prefeed
.It extends
multipipes.Node
to make it pluggable in other Pipelines instances, and makes usage ofself.outqueue
to output the data.A changefeed is a real time feed on inserts, updates, and deletes, and is volatile. This class is a helper to create changefeeds. Moreover, it provides a way to specify a
prefeed
of iterable data to output before the actual changefeed.