You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/llarp/dht/message.hpp

49 lines
1000 B
C++

#ifndef LLARP_DHT_MESSAGE_HPP
#define LLARP_DHT_MESSAGE_HPP
#include <dht/dht.h>
#include <dht/key.hpp>
#include <path/path_types.hpp>
#include <util/bencode.hpp>
#include <vector>
namespace llarp
{
namespace dht
{
constexpr size_t MAX_MSG_SIZE = 2048;
struct IMessage : public IBEncodeMessage
{
virtual ~IMessage()
{
}
/// construct
IMessage(const Key_t& from) : From(from)
{
}
5 years ago
using Ptr_t = std::unique_ptr< IMessage >;
virtual bool
5 years ago
HandleMessage(struct llarp_dht_context* dht,
std::vector< Ptr_t >& replies) const = 0;
Key_t From;
PathID_t pathID;
};
5 years ago
IMessage::Ptr_t
DecodeMessage(const Key_t& from, llarp_buffer_t* buf, bool relayed = false);
bool
DecodeMesssageList(Key_t from, llarp_buffer_t* buf,
5 years ago
std::vector< IMessage::Ptr_t >& dst,
bool relayed = false);
} // namespace dht
} // namespace llarp
#endif