mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
parent
9aab19f349
commit
f68f92776b
6 changed files with 24 additions and 12 deletions
|
@ -48,7 +48,7 @@ namespace levin
|
|||
{
|
||||
uint64_t m_signature;
|
||||
uint64_t m_cb;
|
||||
bool m_have_to_return_data;
|
||||
uint8_t m_have_to_return_data;
|
||||
uint32_t m_command;
|
||||
int32_t m_return_code;
|
||||
uint32_t m_reservedA; //probably some flags in future
|
||||
|
@ -63,7 +63,7 @@ namespace levin
|
|||
{
|
||||
uint64_t m_signature;
|
||||
uint64_t m_cb;
|
||||
bool m_have_to_return_data;
|
||||
uint8_t m_have_to_return_data;
|
||||
uint32_t m_command;
|
||||
int32_t m_return_code;
|
||||
uint32_t m_flags;
|
||||
|
|
|
@ -82,7 +82,7 @@ int levin_client_impl::invoke(int command, const epee::span<const uint8_t> in_bu
|
|||
bucket_head head = {0};
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = SWAP64LE(in_buff.size());
|
||||
head.m_have_to_return_data = true;
|
||||
head.m_have_to_return_data = 1;
|
||||
head.m_command = SWAP32LE(command);
|
||||
if(!m_transport.send(&head, sizeof(head)))
|
||||
return -1;
|
||||
|
@ -118,7 +118,7 @@ int levin_client_impl::notify(int command, const std::string& in_buff)
|
|||
bucket_head head = {0};
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = SWAP64LE(in_buff.size());
|
||||
head.m_have_to_return_data = false;
|
||||
head.m_have_to_return_data = 0;
|
||||
head.m_command = SWAP32LE(command);
|
||||
|
||||
if(!m_transport.send((const char*)&head, sizeof(head)))
|
||||
|
@ -141,7 +141,7 @@ inline
|
|||
bucket_head2 head = {0};
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = SWAP64LE(in_buff.size());
|
||||
head.m_have_to_return_data = true;
|
||||
head.m_have_to_return_data = 1;
|
||||
head.m_command = SWAP32LE(command);
|
||||
head.m_return_code = SWAP32LE(0);
|
||||
head.m_flags = SWAP32LE(LEVIN_PACKET_REQUEST);
|
||||
|
@ -179,7 +179,7 @@ inline
|
|||
bucket_head2 head = {0};
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = SWAP64LE(in_buff.size());
|
||||
head.m_have_to_return_data = false;
|
||||
head.m_have_to_return_data = 0;
|
||||
head.m_command = SWAP32LE(command);
|
||||
head.m_return_code = SWAP32LE(0);
|
||||
head.m_flags = SWAP32LE(LEVIN_PACKET_REQUEST);
|
||||
|
|
|
@ -242,7 +242,7 @@ namespace levin
|
|||
bucket_head head = {0};
|
||||
head.m_signature = LEVIN_SIGNATURE;
|
||||
head.m_cb = in_buff.size();
|
||||
head.m_have_to_return_data = true;
|
||||
head.m_have_to_return_data = 1;
|
||||
head.m_id = target;
|
||||
#ifdef TRACE_LEVIN_PACKETS_BY_GUIDS
|
||||
::UuidCreate(&head.m_id);
|
||||
|
@ -320,7 +320,7 @@ namespace levin
|
|||
bucket_head head = {0};
|
||||
head.m_signature = LEVIN_SIGNATURE;
|
||||
head.m_cb = in_buff.size();
|
||||
head.m_have_to_return_data = false;
|
||||
head.m_have_to_return_data = 0;
|
||||
head.m_id = target;
|
||||
#ifdef TRACE_LEVIN_PACKETS_BY_GUIDS
|
||||
::UuidCreate(&head.m_id);
|
||||
|
@ -510,7 +510,7 @@ namespace levin
|
|||
|
||||
|
||||
head.m_cb = return_buff.size();
|
||||
head.m_have_to_return_data = false;
|
||||
head.m_have_to_return_data = 0;
|
||||
head.m_protocol_version = LEVIN_PROTOCOL_VER_1;
|
||||
head.m_flags = LEVIN_PACKET_RESPONSE;
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace levin
|
|||
levin::bucket_head& head = *(levin::bucket_head*)(&buff[0]);
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = 0;
|
||||
head.m_have_to_return_data = true;
|
||||
head.m_have_to_return_data = 1;
|
||||
head.m_command = SWAP32LE(command_id);
|
||||
head.m_return_code = SWAP32LE(1);
|
||||
head.m_reservedA = rand(); //probably some flags in future
|
||||
|
@ -68,7 +68,7 @@ namespace levin
|
|||
levin::bucket_head& head = *(levin::bucket_head*)(&buff[0]);
|
||||
head.m_signature = SWAP64LE(LEVIN_SIGNATURE);
|
||||
head.m_cb = 0;
|
||||
head.m_have_to_return_data = true;
|
||||
head.m_have_to_return_data = 1;
|
||||
head.m_command = SWAP32LE(command_id);
|
||||
head.m_return_code = SWAP32LE(1);
|
||||
head.m_reservedA = rand(); //probably some flags in future
|
||||
|
|
|
@ -156,7 +156,7 @@ namespace levin
|
|||
std::string return_buff;
|
||||
m_current_head.m_return_code = m_config.m_pcommands_handler->invoke(m_current_head.m_command, buff_to_invoke, return_buff, m_conn_context);
|
||||
m_current_head.m_cb = return_buff.size();
|
||||
m_current_head.m_have_to_return_data = false;
|
||||
m_current_head.m_have_to_return_data = 0;
|
||||
|
||||
return_buff.insert(0, (const char*)&m_current_head, sizeof(m_current_head));
|
||||
if(!m_psnd_hndlr->do_send(byte_slice{std::move(return_buff)}))
|
||||
|
|
|
@ -157,6 +157,18 @@ namespace epee
|
|||
pod_val = CONVERT_POD(pod_val);
|
||||
}
|
||||
|
||||
template<>
|
||||
void throwable_buffer_reader::read<bool>(bool& pod_val)
|
||||
{
|
||||
RECURSION_LIMITATION();
|
||||
static_assert(std::is_pod<bool>::value, "POD type expected");
|
||||
static_assert(sizeof(bool) == sizeof(uint8_t), "We really shouldn't use bool directly in serialization code. Replace it with uint8_t if this assert triggers!");
|
||||
uint8_t t;
|
||||
read(&t, sizeof(t));
|
||||
CHECK_AND_ASSERT_THROW_MES(t <= 1, "Invalid bool value " << t);
|
||||
pod_val = (t != 0);
|
||||
}
|
||||
|
||||
template<class t_type>
|
||||
t_type throwable_buffer_reader::read()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue