OpenCBDC Transaction Processor
|
Implementation of a broker. More...
#include <impl.hpp>
Public Member Functions | |
impl (runtime_locking_shard::broker_id_type broker_id, std::vector< std::shared_ptr< runtime_locking_shard::interface > > shards, std::shared_ptr< ticket_machine::interface > ticketer, std::shared_ptr< directory::interface > directory, std::shared_ptr< logging::log > logger) | |
Constructor. | |
auto | begin (begin_callback_type result_callback) -> bool override |
Requests a new ticket number from the ticket machine. | |
auto | try_lock (ticket_number_type ticket_number, key_type key, lock_type locktype, try_lock_callback_type result_callback) -> bool override |
Determines the shard responsible for the given key and issues a try lock request for the key. | |
auto | commit (ticket_number_type ticket_number, state_update_type state_updates, commit_callback_type result_callback) -> bool override |
Commits the ticket on all shards involved in the ticket. | |
auto | finish (ticket_number_type ticket_number, finish_callback_type result_callback) -> bool override |
Finishes the ticket on all shards involved in the ticket. | |
auto | rollback (ticket_number_type ticket_number, rollback_callback_type result_callback) -> bool override |
Rolls back the ticket on all shards involved in the ticket. | |
auto | recover (recover_callback_type result_callback) -> bool override |
Requests tickets managed by this broker ID from all shards and completes partially committed tickets, and rolls back all other tickets. | |
auto | highest_ticket () -> ticket_number_type override |
Get the highest ticket number that was used. | |
![]() | |
virtual | ~interface ()=default |
interface ()=default | |
interface (const interface &)=delete | |
auto | operator= (const interface &) -> interface &=delete |
interface (interface &&)=delete | |
auto | operator= (interface &&) -> interface &=delete |
Additional Inherited Members | |
![]() | |
enum class | error_code : uint8_t { ticket_number_assignment , unknown_ticket , prepared , shard_unreachable , ticket_machine_unreachable , committed , not_prepared , begun , aborted , directory_unreachable , invalid_shard_state , waiting_for_locks , commit_error , rollback_error , prepare_error , finish_error , get_tickets_error , commit_hazard } |
Error codes returned by broker operations. More... | |
using | ticketnum_or_errcode_type = std::variant<ticket_number_type, error_code> |
Return type from a begin operation. | |
using | begin_callback_type = std::function<void(ticketnum_or_errcode_type)> |
Callback function type for a begin operation. | |
using | try_lock_return_type |
Return type from a try lock operation. | |
using | try_lock_callback_type = std::function<void(try_lock_return_type)> |
Callback function type for a try lock operation. | |
using | commit_return_type |
Return type from a commit operation. | |
using | commit_callback_type = std::function<void(commit_return_type)> |
Callback function type for a commit operation. | |
using | finish_return_type = std::optional<error_code> |
Return type from a finish operation. | |
using | finish_callback_type = std::function<void(finish_return_type)> |
Callback function type for a finish operation. | |
using | rollback_return_type |
Return type from a rollback operation. | |
using | rollback_callback_type = std::function<void(rollback_return_type)> |
Callback function type for a rollback operation. | |
using | recover_return_type = std::optional<error_code> |
Return type from a recover operation. | |
using | recover_callback_type = std::function<void(recover_return_type)> |
Callback function type for a recovery operation. | |
Implementation of a broker.
Stores ticket states in memory. Thread-safe.
Definition at line 18 of file broker/impl.hpp.
cbdc::parsec::broker::impl::impl | ( | runtime_locking_shard::broker_id_type | broker_id, |
std::vector< std::shared_ptr< runtime_locking_shard::interface > > | shards, | ||
std::shared_ptr< ticket_machine::interface > | ticketer, | ||
std::shared_ptr< directory::interface > | directory, | ||
std::shared_ptr< logging::log > | logger ) |
Constructor.
broker_id | unique ID of this broker instance. |
shards | vector of shard instances. |
ticketer | ticket machine instance. |
directory | directory instance. |
logger | log instance. |
Definition at line 13 of file broker/impl.cpp.
|
overridevirtual |
Requests a new ticket number from the ticket machine.
result_callback | function to call with the begin result. |
Implements cbdc::parsec::broker::interface.
Definition at line 25 of file broker/impl.cpp.
|
overridevirtual |
Commits the ticket on all shards involved in the ticket.
ticket_number | ticket number. |
state_updates | state updates to apply if ticket commits. |
result_callback | function to call with commit result. |
We should fail here, because if this transaction has made it to the commit step without attempting to lock the keys, something signficant has gone wrong, likely associated with the contract itself.
Implements cbdc::parsec::broker::interface.
Definition at line 376 of file broker/impl.cpp.
References cbdc::buffer.
|
overridevirtual |
Finishes the ticket on all shards involved in the ticket.
ticket_number | ticket number. |
result_callback | function to call with finish result. |
Implements cbdc::parsec::broker::interface.
Definition at line 492 of file broker/impl.cpp.
|
overridevirtual |
Get the highest ticket number that was used.
This is not to be used for calculating a next ticket number, but is used to calculate the pretend height of the chain in the evm runner, which is derived from ticket numbers
Implements cbdc::parsec::broker::interface.
Definition at line 70 of file broker/impl.cpp.
|
overridevirtual |
Requests tickets managed by this broker ID from all shards and completes partially committed tickets, and rolls back all other tickets.
Finishes all tickets.
result_callback | function to call with recovery result. |
Implements cbdc::parsec::broker::interface.
Definition at line 882 of file broker/impl.cpp.
|
overridevirtual |
Rolls back the ticket on all shards involved in the ticket.
ticket_number | ticket number. |
result_callback | function to call with rollback result. |
Implements cbdc::parsec::broker::interface.
Definition at line 571 of file broker/impl.cpp.
|
overridevirtual |
Determines the shard responsible for the given key and issues a try lock request for the key.
ticket_number | ticket number. |
key | key to lock. |
locktype | type of lock to acquire. |
result_callback | function to call with try_lock request. |
Implements cbdc::parsec::broker::interface.
Definition at line 132 of file broker/impl.cpp.