lokinet/llarp/dht/messages/findintro.hpp

62 lines
1.5 KiB
C++
Raw Normal View History

#ifndef LLARP_DHT_MESSAGES_FIND_INTRO_HPP
#define LLARP_DHT_MESSAGES_FIND_INTRO_HPP
2018-12-12 02:04:32 +00:00
2018-12-12 00:48:54 +00:00
#include <dht/message.hpp>
2018-12-12 02:04:32 +00:00
#include <routing/message.hpp>
2018-12-12 02:15:08 +00:00
#include <service/address.hpp>
#include <service/tag.hpp>
namespace llarp
{
namespace dht
{
struct FindIntroMessage final : public IMessage
{
2020-01-23 12:22:40 +00:00
static const uint64_t MaxRecursionDepth;
uint64_t recursionDepth = 0;
2020-01-27 21:30:41 +00:00
Key_t location;
llarp::service::Tag tagName;
uint64_t txID = 0;
bool relayed = false;
FindIntroMessage(const Key_t& from, bool relay) : IMessage(from)
{
relayed = relay;
}
FindIntroMessage(const llarp::service::Tag& tag, uint64_t txid,
2018-11-08 15:15:02 +00:00
bool iterate = true)
: IMessage({}), tagName(tag), txID(txid)
2018-07-18 03:10:21 +00:00
{
2018-11-08 15:15:02 +00:00
if(iterate)
recursionDepth = 0;
2018-11-08 15:15:02 +00:00
else
recursionDepth = 1;
2018-07-18 03:10:21 +00:00
}
2020-01-27 21:30:41 +00:00
explicit FindIntroMessage(uint64_t txid, const Key_t& addr,
2020-01-23 12:22:40 +00:00
uint64_t maxRecursionDepth)
: IMessage({})
, recursionDepth(maxRecursionDepth)
2020-01-27 21:30:41 +00:00
, location(addr)
, txID(txid)
2018-07-18 03:10:21 +00:00
{
tagName.Zero();
2018-07-18 03:10:21 +00:00
}
2019-07-30 23:42:13 +00:00
~FindIntroMessage() override;
bool
BEncode(llarp_buffer_t* buf) const override;
bool
2019-02-05 00:41:33 +00:00
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
bool
2019-05-03 13:15:03 +00:00
HandleMessage(llarp_dht_context* ctx,
std::vector< IMessage::Ptr_t >& replies) const override;
};
2018-07-12 18:21:44 +00:00
} // namespace dht
} // namespace llarp
2018-08-29 20:40:26 +00:00
#endif