mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
273270916e
This commit reflects changes to clang-format rules. Unfortunately, these rule changes create a massive change to the codebase, which causes an apparent rewrite of git history. Git blame's --ignore-rev flag can be used to ignore this commit when attempting to `git blame` some code.
52 lines
1.1 KiB
C++
52 lines
1.1 KiB
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
|
|
{
|
|
virtual ~IMessage() = default;
|
|
|
|
/// construct
|
|
IMessage(const Key_t& from) : From(from)
|
|
{
|
|
}
|
|
|
|
using Ptr_t = std::unique_ptr<IMessage>;
|
|
|
|
virtual bool
|
|
HandleMessage(struct llarp_dht_context* dht, std::vector<Ptr_t>& replies) const = 0;
|
|
|
|
virtual bool
|
|
BEncode(llarp_buffer_t* buf) const = 0;
|
|
|
|
virtual bool
|
|
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) = 0;
|
|
|
|
Key_t From;
|
|
PathID_t pathID;
|
|
uint64_t version = LLARP_PROTO_VERSION;
|
|
};
|
|
|
|
IMessage::Ptr_t
|
|
DecodeMessage(const Key_t& from, llarp_buffer_t* buf, bool relayed = false);
|
|
|
|
bool
|
|
DecodeMesssageList(
|
|
Key_t from, llarp_buffer_t* buf, std::vector<IMessage::Ptr_t>& dst, bool relayed = false);
|
|
} // namespace dht
|
|
} // namespace llarp
|
|
|
|
#endif
|