lokinet/llarp/dht/messages/findintro.hpp

64 lines
1.4 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
{
2018-08-10 03:51:38 +00:00
uint64_t R = 0;
llarp::service::Address S;
2018-07-17 07:30:03 +00:00
llarp::service::Tag N;
uint64_t T = 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({}), N(tag), T(txid)
2018-07-18 03:10:21 +00:00
{
S.Zero();
2018-11-08 15:15:02 +00:00
if(iterate)
R = 0;
else
R = 1;
2018-07-18 03:10:21 +00:00
}
2018-08-29 20:40:26 +00:00
FindIntroMessage(uint64_t txid, const llarp::service::Address& addr,
2018-11-08 15:15:02 +00:00
bool iterate = true)
: IMessage({}), S(addr), T(txid)
2018-07-18 03:10:21 +00:00
{
N.Zero();
2018-11-08 15:15:02 +00:00
if(iterate)
R = 0;
else
R = 1;
2018-07-18 03:10:21 +00:00
}
~FindIntroMessage();
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
HandleMessage(
llarp_dht_context* ctx,
std::vector< std::unique_ptr< IMessage > >& replies) const override;
};
2018-07-12 18:21:44 +00:00
} // namespace dht
} // namespace llarp
2018-08-29 20:40:26 +00:00
#endif