OpenCBDC Transaction Processor
Loading...
Searching...
No Matches
uhs/twophase/coordinator/format.cpp
Go to the documentation of this file.
1// Copyright (c) 2021 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#include "format.hpp"
7
8#include "controller.hpp"
9#include "state_machine.hpp"
13
14namespace cbdc {
17 -> serializer& {
18 return ser << s.m_prepare_txs << s.m_commit_txs << s.m_discard_txs;
19 }
20
23 -> serializer& {
24 return deser >> s.m_prepare_txs >> s.m_commit_txs >> s.m_discard_txs;
25 }
26
29 -> serializer& {
30 ser << c.m_header;
31 switch(c.m_header.m_comm) {
33 const auto& data
34 = std::get<coordinator::controller::prepare_tx>(
35 c.m_data.value());
36 ser << data;
37 break;
38 }
40 const auto& data
41 = std::get<coordinator::controller::commit_tx>(
42 c.m_data.value());
43 ser << data;
44 break;
45 }
46 // Discard, done and get don't have a payload
50 break;
51 }
52 }
53 return ser;
54 }
55
58 -> serializer& {
59 return ser << static_cast<uint8_t>(c.m_comm) << c.m_dtx_id;
60 }
61
64 -> serializer& {
65 uint8_t comm{};
66 deser >> comm;
67 c.m_comm = static_cast<coordinator::state_machine::command>(comm);
68 deser >> c.m_dtx_id;
69 return deser;
70 }
71}
command
Types of command the state machine can process.
@ prepare
Stores a dtx in the prepare phase.
@ done
Clears the dtx from the coordinator state.
@ discard
Moves a dtx from commit to discard.
@ get
Retrieves all active dtxs.
@ commit
Moves a dtx from prepare to commit.
Interface for serializing objects into and out of raw bytes representations.
auto operator>>(serializer &deser, parsec::agent::rpc::request &req) -> serializer &
auto operator<<(serializer &ser, const parsec::agent::rpc::request &req) -> serializer &
Current state of distributed transactions managed by a coordinator.
A full command for the state machine to process.
Used to store dtxs, which phase they are in and relevant data require for recovery.