2018-07-11 13:20:14 +00:00
|
|
|
#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>
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dht
|
|
|
|
{
|
2018-11-05 11:27:12 +00:00
|
|
|
struct FindIntroMessage final : public IMessage
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
2020-01-23 12:22:40 +00:00
|
|
|
static const uint64_t MaxRecursionDepth;
|
2020-01-23 12:11:11 +00:00
|
|
|
uint64_t recursionDepth = 0;
|
2020-01-27 21:30:41 +00:00
|
|
|
Key_t location;
|
2020-01-23 12:11:11 +00:00
|
|
|
llarp::service::Tag tagName;
|
2020-02-13 22:19:12 +00:00
|
|
|
uint64_t txID = 0;
|
|
|
|
bool relayed = false;
|
|
|
|
uint32_t relayOrder = 0;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2020-02-13 22:19:12 +00:00
|
|
|
FindIntroMessage(const Key_t& from, bool relay, uint32_t order)
|
|
|
|
: IMessage(from)
|
2018-07-16 21:22:25 +00:00
|
|
|
{
|
2020-02-13 22:19:12 +00:00
|
|
|
relayed = relay;
|
|
|
|
relayOrder = order;
|
2018-07-16 21:22:25 +00:00
|
|
|
}
|
|
|
|
|
2018-10-21 14:19:49 +00:00
|
|
|
FindIntroMessage(const llarp::service::Tag& tag, uint64_t txid,
|
2018-11-08 15:15:02 +00:00
|
|
|
bool iterate = true)
|
2020-01-23 12:11:11 +00:00
|
|
|
: IMessage({}), tagName(tag), txID(txid)
|
2018-07-18 03:10:21 +00:00
|
|
|
{
|
2018-11-08 15:15:02 +00:00
|
|
|
if(iterate)
|
2020-01-23 12:11:11 +00:00
|
|
|
recursionDepth = 0;
|
2018-11-08 15:15:02 +00:00
|
|
|
else
|
2020-01-23 12:11:11 +00:00
|
|
|
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-02-13 22:19:12 +00:00
|
|
|
uint64_t maxRecursionDepth, uint32_t order)
|
2020-01-23 12:11:11 +00:00
|
|
|
: IMessage({})
|
|
|
|
, recursionDepth(maxRecursionDepth)
|
2020-01-27 21:30:41 +00:00
|
|
|
, location(addr)
|
2020-01-23 12:11:11 +00:00
|
|
|
, txID(txid)
|
2020-02-13 22:19:12 +00:00
|
|
|
, relayOrder(order)
|
2018-07-18 03:10:21 +00:00
|
|
|
{
|
2020-01-23 12:11:11 +00:00
|
|
|
tagName.Zero();
|
2018-07-18 03:10:21 +00:00
|
|
|
}
|
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
~FindIntroMessage() override;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
bool
|
2018-11-05 11:27:12 +00:00
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
bool
|
2019-02-05 00:41:33 +00:00
|
|
|
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2018-07-16 21:22:25 +00:00
|
|
|
bool
|
2019-05-03 13:15:03 +00:00
|
|
|
HandleMessage(llarp_dht_context* ctx,
|
|
|
|
std::vector< IMessage::Ptr_t >& replies) const override;
|
2018-07-16 21:22:25 +00:00
|
|
|
};
|
2018-07-12 18:21:44 +00:00
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|
2018-08-29 20:40:26 +00:00
|
|
|
#endif
|