Engine is the core component that runs the Tashi Vertex consensus algorithm. It manages the network communication, transaction processing, and event ordering.
Methods
start
Starts the consensus engine.Parameters
Reference to a Tashi Vertex context
A bound socket for network communication. Ownership is transferred to the engine.
Configuration options for the engine. Ownership is transferred to the engine.
The secret key used for signing transactions and events
The set of peer nodes to connect to. Ownership is transferred to the engine.
Returns
Returns an
Engine instance on success, or an Error if the engine fails to start.The
socket, options, and peers parameters transfer ownership to the engine. They cannot be used after calling start().Example
recv_message
Listens for the next incoming message on the given engine.Returns
Returns
Some(Message) when a message is received, None when the engine is shutting down, or an Error if an error occurs.Message enum can be one of:
Message::Event(Event)- A consensus event that has been orderedMessage::SyncPoint(SyncPoint)- A synchronization point in the consensus
Example
This method is asynchronous and will await the next message. It’s typically called in a loop to continuously process messages.
send_transaction
Sends a transaction to the network.Parameters
The transaction to send. Ownership is transferred to the engine.
Returns
Returns
Ok(()) on success, or an Error if the transaction fails to send.Example
Complete usage example
- Basic setup
- With transactions
Related types
- Context - Required to start the engine
- Socket - Network socket transferred to the engine
- Options - Configuration options transferred to the engine
- KeySecret - Secret key for signing operations
- Peers - Peer set transferred to the engine
- Transaction - Transactions to send to the network
- Message - Messages received from the engine
- Event - Consensus events
- SyncPoint - Synchronization points