MCPcopy Create free account
hub / github.com/bcndev/bytecoin / read_command_header

Method read_command_header

src/p2p/LevinProtocol.cpp:72–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70size_t LevinProtocol::HEADER_SIZE() { return sizeof(bucket_head2); }
71
72size_t LevinProtocol::read_command_header(const BinaryArray &raw_header, CommandType *rrn, uint32_t *command) {
73 bucket_head2 head = {};
74 if (raw_header.size() != sizeof(head))
75 throw std::runtime_error("Levin wrong header size " + common::to_string(raw_header.size()));
76 memmove(&head, raw_header.data(), sizeof(head)); // TODO - endian
77
78 if (head.m_magic != LEVIN_MAGIC)
79 throw std::runtime_error("Levin magic mismatch raw_header=" + common::to_hex(raw_header));
80
81 *command = head.m_command;
82 *rrn = (head.m_flags & LEVIN_PACKET_RESPONSE) == LEVIN_PACKET_RESPONSE ? RESPONSE
83 : head.m_command_type ? REQUEST : NOTIFY;
84 return common::integer_cast<size_t>(head.m_cb);
85}

Callers

nothing calls this directly

Calls 4

to_stringFunction · 0.50
to_hexFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected