Barretenberg
The ZK-SNARK library at the core of Aztec
Loading...
Searching...
No Matches
header.hpp
Go to the documentation of this file.
1#pragma once
3#include <cstdint>
4#include <cstring>
5
6namespace bb::messaging {
7
8enum SystemMsgTypes { TERMINATE = 0, PING = 1, PONG = 2 };
9
10const uint32_t FIRST_APP_MSG_TYPE = 100;
11
12// #pragma pack(push, 1)
13struct MsgHeader {
14 uint32_t messageId; // Unique Id for the message
15 uint32_t requestId; // Id of the message this is responding too (may not be used)
16
18
19 MsgHeader() = default;
20
21 MsgHeader(uint32_t reqId)
22 : requestId(reqId)
23 {}
24
25 MsgHeader(uint32_t msgId, uint32_t reqId)
26 : messageId(msgId)
27 , requestId(reqId)
28 {}
29};
30
32 uint32_t msgType;
34
35 HeaderOnlyMessage(uint32_t type, MsgHeader& hdr)
36 : msgType(type)
37 , header(hdr)
38 {}
39
40 HeaderOnlyMessage() = default;
41
43};
44
45template <class T> struct TypedMessage {
46 uint32_t msgType;
49
50 TypedMessage(uint32_t type, MsgHeader& hdr, const T& val)
51 : msgType(type)
52 , header(hdr)
53 , value(val)
54 {}
55
56 TypedMessage() = default;
57
59};
60
61// #pragma pack(pop)
62} // namespace bb::messaging
const uint32_t FIRST_APP_MSG_TYPE
Definition header.hpp:10
HeaderOnlyMessage(uint32_t type, MsgHeader &hdr)
Definition header.hpp:35
MSGPACK_FIELDS(messageId, requestId)
MsgHeader(uint32_t msgId, uint32_t reqId)
Definition header.hpp:25
MsgHeader(uint32_t reqId)
Definition header.hpp:21
MSGPACK_FIELDS(msgType, header, value)
TypedMessage(uint32_t type, MsgHeader &hdr, const T &val)
Definition header.hpp:50