OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
replicated_shard.hpp
Go to the documentation of this file.
1// Copyright (c) 2022 MIT Digital Currency Initiative,
2// Federal Reserve Bank of Boston
3// Distributed under the MIT software license, see the accompanying
4// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6#ifndef OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_H_
7#define OPENCBDC_TX_SRC_PARSEC_RUNTIME_LOCKING_SHARD_REPLICATED_SHARD_H_
8
10
11#include <mutex>
12
17 public:
20 auto prepare(ticket_number_type ticket_number,
21 broker_id_type broker_id,
22 state_type state_update,
23 callback_type result_callback) -> bool override;
24
27 auto commit(ticket_number_type ticket_number,
28 callback_type result_callback) -> bool override;
29
32 auto finish(ticket_number_type ticket_number,
33 callback_type result_callback) -> bool override;
34
37 auto get_tickets(get_tickets_callback_type result_callback) const
38 -> bool override;
39
42 auto get_state() const -> state_type;
43
44 private:
45 mutable std::mutex m_mut;
46 state_type m_state;
47 tickets_type m_tickets;
48 };
49}
50
51#endif
Interface for replicating internal state for prepared and committed tickets managed by a locking shar...
std::function< void(get_tickets_return_type)> get_tickets_callback_type
Callback function type for the result of a get tickets operation.
std::unordered_map< ticket_number_type, ticket_type > tickets_type
Type for the tickets list returned by the state machine.
std::function< void(return_type)> callback_type
Callback function type for the result of a prepare operation.
std::unordered_map< key_type, value_type, hashing::const_sip_hash< key_type > > state_type
Type for state updates to a shard.
Implementation of the replicated shard interface.
auto get_tickets(get_tickets_callback_type result_callback) const -> bool override
Retrieves unfinished tickets from the state machine.
auto get_state() const -> state_type
Return the keys and values stored by the shard.
auto prepare(ticket_number_type ticket_number, broker_id_type broker_id, state_type state_update, callback_type result_callback) -> bool override
Stores a prepare request for a ticket in the state machine.
auto commit(ticket_number_type ticket_number, callback_type result_callback) -> bool override
Stores a commit request in the state machine.
auto finish(ticket_number_type ticket_number, callback_type result_callback) -> bool override
Stores a finish request in the state machine.
parsec::ticket_machine::ticket_number_type ticket_number_type
Type for a ticket number.