1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00
lokinet/llarp/dht/messages/gotintro.hpp
Thomas Winget 7caa87862e standardize include format and pragma once
All #ifndef guards on headers have been removed, I think,
in favor of #pragma once

Headers are now included as `#include "filename"` if the included file
resides in the same directory as the file including it, or any
subdirectory therein.  Otherwise they are included as
`#include <project/top/dir/relative/path/filename>`

The above does not include system/os headers.
2021-03-09 19:01:41 -05:00

64 lines
1.8 KiB
C++

#pragma once
#include <llarp/dht/message.hpp>
#include <llarp/service/intro_set.hpp>
#include <llarp/util/copy_or_nullptr.hpp>
#include <vector>
#include <optional>
namespace llarp
{
namespace dht
{
/// acknowledgement to PublishIntroMessage or reply to FindIntroMessage
struct GotIntroMessage : public IMessage
{
/// the found introsets
std::vector<service::EncryptedIntroSet> found;
/// txid
uint64_t txid = 0;
/// the key of a router closer in keyspace if iterative lookup
std::optional<Key_t> closer;
GotIntroMessage(const Key_t& from) : IMessage(from)
{}
GotIntroMessage(const GotIntroMessage& other)
: IMessage(other.From), found(other.found), txid(other.txid), closer(other.closer)
{
version = other.version;
}
/// for iterative reply
GotIntroMessage(const Key_t& from, const Key_t& _closer, uint64_t _txid)
: IMessage(from), txid(_txid), closer(_closer)
{}
/// for recursive reply
GotIntroMessage(std::vector<service::EncryptedIntroSet> results, uint64_t txid);
~GotIntroMessage() override = default;
bool
BEncode(llarp_buffer_t* buf) const override;
bool
DecodeKey(const llarp_buffer_t& key, llarp_buffer_t* val) override;
bool
HandleMessage(llarp_dht_context* ctx, std::vector<IMessage::Ptr_t>& replies) const override;
};
struct RelayedGotIntroMessage final : public GotIntroMessage
{
RelayedGotIntroMessage() : GotIntroMessage({})
{}
bool
HandleMessage(llarp_dht_context* ctx, std::vector<IMessage::Ptr_t>& replies) const override;
};
using GotIntroMessage_constptr = std::shared_ptr<const GotIntroMessage>;
} // namespace dht
} // namespace llarp