You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/llarp/dht/messages/gotintro.hpp

75 lines
1.9 KiB
C++

#ifndef LLARP_DHT_MESSAGES_GOT_INTRO_HPP
#define LLARP_DHT_MESSAGES_GOT_INTRO_HPP
#include <dht/message.hpp>
#include <service/intro_set.hpp>
5 years ago
#include <util/copy_or_nullptr.hpp>
6 years ago
#include <vector>
namespace llarp
{
namespace dht
{
/// acknowledgement to PublishIntroMessage or reply to FindIntroMessage
struct GotIntroMessage : public IMessage
{
/// the found introsets
6 years ago
std::vector< llarp::service::IntroSet > I;
/// txid
uint64_t T = 0;
/// the key of a router closer in keyspace if iterative lookup
std::unique_ptr< Key_t > K;
GotIntroMessage(const Key_t& from) : IMessage(from)
{
}
5 years ago
GotIntroMessage(const GotIntroMessage& other)
: IMessage(other.From)
, I(other.I)
, T(other.T)
, K(copy_or_nullptr(other.K))
{
version = other.version;
}
/// 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
6 years ago
GotIntroMessage(const std::vector< llarp::service::IntroSet >& results,
6 years ago
uint64_t txid);
~GotIntroMessage();
bool
BEncode(llarp_buffer_t* buf) const override;
bool
5 years ago
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
virtual bool
5 years ago
HandleMessage(llarp_dht_context* ctx,
std::vector< IMessage::Ptr_t >& replies) const override;
};
struct RelayedGotIntroMessage final : public GotIntroMessage
{
RelayedGotIntroMessage() : GotIntroMessage({})
{
}
bool
5 years ago
HandleMessage(llarp_dht_context* ctx,
std::vector< IMessage::Ptr_t >& replies) const override;
};
5 years ago
using GotIntroMessage_constptr = std::shared_ptr< const GotIntroMessage >;
} // namespace dht
} // namespace llarp
#endif