lokinet/llarp/messages/relay_commit.hpp

87 lines
1.6 KiB
C++
Raw Normal View History

#ifndef LLARP_RELAY_COMMIT_HPP
#define LLARP_RELAY_COMMIT_HPP
#include <crypto/encrypted_frame.hpp>
#include <crypto/types.hpp>
#include <messages/link_message.hpp>
2019-01-11 01:19:36 +00:00
#include <path/path_types.hpp>
#include <pow.hpp>
2018-12-12 01:32:10 +00:00
2018-09-17 18:43:14 +00:00
#include <array>
#include <memory>
namespace llarp
{
2018-06-18 22:03:50 +00:00
// forward declare
struct AbstractRouter;
namespace path
{
struct PathContext;
}
2018-06-18 22:03:50 +00:00
struct LR_CommitRecord
{
PubKey commkey;
2018-06-18 22:03:50 +00:00
RouterID nextHop;
TunnelNonce tunnelNonce;
2018-06-22 00:25:30 +00:00
PathID_t txid, rxid;
std::unique_ptr< RouterContact > nextRC;
std::unique_ptr< PoW > work;
uint64_t version = 0;
2019-05-28 14:07:00 +00:00
uint64_t lifetime = 0;
bool
BDecode(llarp_buffer_t *buf);
bool
2018-06-10 14:05:48 +00:00
BEncode(llarp_buffer_t *buf) const;
2018-06-12 12:49:23 +00:00
2018-06-21 12:55:02 +00:00
bool
operator==(const LR_CommitRecord &other) const;
2018-06-12 12:49:23 +00:00
private:
bool
OnKey(llarp_buffer_t *buffer, llarp_buffer_t *key);
};
2018-06-01 14:08:54 +00:00
struct LR_CommitMessage : public ILinkMessage
{
2018-08-30 18:48:43 +00:00
std::array< EncryptedFrame, 8 > frames;
2019-04-30 12:22:15 +00:00
LR_CommitMessage(const std::array< EncryptedFrame, 8 > &_frames)
: ILinkMessage(), frames(_frames)
{
}
2018-06-12 16:45:12 +00:00
LR_CommitMessage() : ILinkMessage()
{
}
2018-06-18 22:03:50 +00:00
2018-06-01 14:08:54 +00:00
~LR_CommitMessage();
void
2019-03-29 01:02:41 +00:00
Clear() override;
bool
2019-03-29 01:02:41 +00:00
DecodeKey(const llarp_buffer_t &key, llarp_buffer_t *buf) override;
bool
2019-03-29 01:02:41 +00:00
BEncode(llarp_buffer_t *buf) const override;
2018-06-01 14:08:54 +00:00
bool
2019-03-29 01:02:41 +00:00
HandleMessage(AbstractRouter *router) const override;
2018-06-18 22:03:50 +00:00
bool
AsyncDecrypt(llarp::path::PathContext *context) const;
2019-03-26 20:04:41 +00:00
const char *
Name() const override
{
return "RelayCommit";
}
};
2018-06-18 22:03:50 +00:00
} // namespace llarp
#endif