2018-07-11 13:20:14 +00:00
|
|
|
#ifndef LLARP_DHT_MESSAGES_GOT_ROUTER_HPP
|
|
|
|
#define LLARP_DHT_MESSAGES_GOT_ROUTER_HPP
|
|
|
|
#include <llarp/dht/message.hpp>
|
2018-08-30 18:48:43 +00:00
|
|
|
#include <llarp/router_contact.hpp>
|
2018-07-11 13:20:14 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace dht
|
|
|
|
{
|
|
|
|
struct GotRouterMessage : public IMessage
|
|
|
|
{
|
2018-08-10 21:34:11 +00:00
|
|
|
GotRouterMessage(const Key_t& from, bool tunneled)
|
|
|
|
: IMessage(from), relayed(tunneled)
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
|
|
|
}
|
2018-08-30 18:48:43 +00:00
|
|
|
GotRouterMessage(const Key_t& from, uint64_t id,
|
|
|
|
const std::vector< RouterContact >& results,
|
2018-08-10 21:34:11 +00:00
|
|
|
bool tunneled)
|
2018-08-30 18:48:43 +00:00
|
|
|
: IMessage(from), R(results), txid(id), relayed(tunneled)
|
2018-07-11 13:20:14 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-08-27 13:44:16 +00:00
|
|
|
GotRouterMessage(uint64_t id, const std::vector< RouterID >& near,
|
|
|
|
bool tunneled)
|
|
|
|
: IMessage({}), N(near), txid(id), relayed(tunneled)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-07-11 13:20:14 +00:00
|
|
|
~GotRouterMessage();
|
|
|
|
|
|
|
|
bool
|
|
|
|
BEncode(llarp_buffer_t* buf) const;
|
|
|
|
|
|
|
|
bool
|
|
|
|
DecodeKey(llarp_buffer_t key, llarp_buffer_t* val);
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
HandleMessage(llarp_dht_context* ctx,
|
2018-09-02 18:25:42 +00:00
|
|
|
std::vector< std::unique_ptr< IMessage > >& replies) const;
|
2018-07-11 13:20:14 +00:00
|
|
|
|
2018-08-30 18:48:43 +00:00
|
|
|
std::vector< RouterContact > R;
|
2018-08-27 13:44:16 +00:00
|
|
|
std::vector< RouterID > N;
|
2018-07-11 13:20:14 +00:00
|
|
|
uint64_t txid = 0;
|
|
|
|
uint64_t version = 0;
|
2018-08-10 21:34:11 +00:00
|
|
|
bool relayed = false;
|
2018-07-11 13:20:14 +00:00
|
|
|
};
|
2018-07-17 04:37:50 +00:00
|
|
|
} // namespace dht
|
|
|
|
} // namespace llarp
|
2018-08-27 13:44:16 +00:00
|
|
|
#endif
|