2018-07-11 15:20:14 +02:00
|
|
|
#ifndef LLARP_DHT_MESSAGES_GOT_INTRO_HPP
|
|
|
|
#define LLARP_DHT_MESSAGES_GOT_INTRO_HPP
|
2018-12-12 03:15:08 +01:00
|
|
|
|
2018-12-12 01:48:54 +01:00
|
|
|
#include <dht/message.hpp>
|
2018-12-12 03:15:08 +01:00
|
|
|
#include <service/IntroSet.hpp>
|
|
|
|
|
2018-07-20 06:50:28 +02:00
|
|
|
#include <vector>
|
2018-07-11 15:20:14 +02:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dht
|
|
|
|
{
|
2018-11-08 16:15:02 +01:00
|
|
|
/// acknowledgement to PublishIntroMessage or reply to FindIntroMessage
|
2018-07-11 15:20:14 +02:00
|
|
|
struct GotIntroMessage : public IMessage
|
|
|
|
{
|
2018-11-08 16:15:02 +01:00
|
|
|
/// the found introsets
|
2018-07-20 06:50:28 +02:00
|
|
|
std::vector< llarp::service::IntroSet > I;
|
2018-11-08 16:15:02 +01:00
|
|
|
/// txid
|
2018-07-11 18:11:19 +02:00
|
|
|
uint64_t T = 0;
|
2018-11-08 16:15:02 +01:00
|
|
|
/// the key of a router closer in keyspace if iterative lookup
|
|
|
|
std::unique_ptr< Key_t > K;
|
2018-07-11 18:11:19 +02:00
|
|
|
|
2018-07-12 15:43:37 +02:00
|
|
|
GotIntroMessage(const Key_t& from) : IMessage(from)
|
2018-07-11 18:11:19 +02:00
|
|
|
{
|
|
|
|
}
|
2018-07-11 15:20:14 +02:00
|
|
|
|
2018-11-08 16:15:02 +01:00
|
|
|
/// for iterative reply
|
|
|
|
GotIntroMessage(const Key_t& from, const Key_t& closer, uint64_t txid)
|
|
|
|
: IMessage(from), T(txid), K(new Key_t(closer))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// for recursive reply
|
2018-07-20 06:50:28 +02:00
|
|
|
GotIntroMessage(const std::vector< llarp::service::IntroSet >& results,
|
2018-07-18 05:10:21 +02:00
|
|
|
uint64_t txid);
|
2018-07-11 15:20:14 +02:00
|
|
|
|
|
|
|
~GotIntroMessage();
|
|
|
|
|
|
|
|
bool
|
2018-11-05 12:27:12 +01:00
|
|
|
BEncode(llarp_buffer_t* buf) const override;
|
2018-07-11 15:20:14 +02:00
|
|
|
|
|
|
|
bool
|
2019-02-05 01:41:33 +01:00
|
|
|
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
|
2018-07-11 15:20:14 +02:00
|
|
|
|
2018-07-12 15:43:37 +02:00
|
|
|
virtual bool
|
2018-11-05 12:27:12 +01:00
|
|
|
HandleMessage(
|
|
|
|
llarp_dht_context* ctx,
|
|
|
|
std::vector< std::unique_ptr< IMessage > >& replies) const override;
|
2018-07-12 15:43:37 +02:00
|
|
|
};
|
|
|
|
|
2018-11-05 12:27:12 +01:00
|
|
|
struct RelayedGotIntroMessage final : public GotIntroMessage
|
2018-07-12 15:43:37 +02:00
|
|
|
{
|
|
|
|
RelayedGotIntroMessage() : GotIntroMessage({})
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-07-11 18:11:19 +02:00
|
|
|
bool
|
2018-11-05 12:27:12 +01:00
|
|
|
HandleMessage(
|
|
|
|
llarp_dht_context* ctx,
|
|
|
|
std::vector< std::unique_ptr< IMessage > >& replies) const override;
|
2018-07-11 15:20:14 +02:00
|
|
|
};
|
2018-07-12 15:43:37 +02:00
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|
2018-08-29 22:40:26 +02:00
|
|
|
#endif
|