sawtooth.simulator_workload module

class sawtooth.simulator_workload.SawtoothWorkload(delegate, config)[source]

Bases: object

This is meant to be an abstract base class for all workload generators. As such, it doesn’t do anything useful besides define the interface that the workload simulator expects and hold onto one property for derived classes.

Initializes the base class.

Parameters:
  • delegate – The object that supports delegate methods
  • config – A Config object that has run-time configuration

The workload generator uses the delegate object to alert the simulator of certain events.

on_new_transaction(transaction_id, client) is called when a workload generator creates a new transaction.

transaction_id - the transaction ID for the new transaction client - an instance of a class that derives from SawtoothClient. This client is the one to which the transaction was submitted.

delegate
config
on_will_start()[source]

Called by the simulator to let the workload generator do any final setup before the simulator begins.

Parameters:base_validator – The base validator used to prime the simulator.
Returns:Nothing
on_will_stop()[source]

Called by the simulator to let the workload generator do any final cleanup before the simulator tears down.

Returns:Nothing
on_validator_discovered(url)[source]

Called by the simulator to let the workload generator know that it has discovered a new validator in the network. Note that the simulator will begin calling this before on_will_start to let the workload generator know about the initial list of clients.

Parameters:url – The URL for the validator
Returns:Nothing
on_validator_removed(url)[source]

Called by the simulator to let the workload generator know that it has detected that a validator has left the network.

Parameters:url – The URL for the validator
Returns:Nothing
on_all_transactions_committed()[source]

In the normal course of running the simulator loop, this is called by the validator to let the workload generator know that all pending transactions have been completed. This is a hint to create a new transaction.

Returns:Nothing
on_transaction_committed(transaction_id)[source]

In the normal course of running the simulator loop, this is called by the validator to let the workload generator know that a previously- pending transaction has been committed by the validator to which it was submitted.

Parameters:transaction_id – The transaction that has been committed.
Returns:Nothing
on_transaction_not_yet_committed(transaction_id)[source]

In the normal course of running the simulator loop, this is called by the validator to let the workload generator know that a previously- pending transaction’s status was checked and it is still pending.

Parameters:transaction_id – The transaction that was checked.
Returns:Put transaction back in the queue of transactions to check False: Don’t bother checking the transaction’s status any more
Return type:True