mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-03 23:15:52 +00:00
cecbddc912
Fixes a subtle memory leak that was a result of outbound messages which were in the shared queue (not yet sorted into a per-path queue) when a path was removed, resulting in a ghost path queue (and thus round-robin order entry as well). Adds much needed documentation to the outbound message handler class.
48 lines
913 B
C++
48 lines
913 B
C++
#pragma once
|
|
|
|
#include <llarp/util/status.hpp>
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
|
|
namespace llarp
|
|
{
|
|
enum class SendStatus
|
|
{
|
|
Success,
|
|
Timeout,
|
|
NoLink,
|
|
InvalidRouter,
|
|
RouterNotFound,
|
|
Congestion
|
|
};
|
|
|
|
struct ILinkMessage;
|
|
struct RouterID;
|
|
struct PathID_t;
|
|
|
|
using SendStatusHandler = std::function<void(SendStatus)>;
|
|
|
|
static const size_t MAX_PATH_QUEUE_SIZE = 100;
|
|
static const size_t MAX_OUTBOUND_QUEUE_SIZE = 1000;
|
|
static const size_t MAX_OUTBOUND_MESSAGES_PER_TICK = 500;
|
|
|
|
struct IOutboundMessageHandler
|
|
{
|
|
virtual ~IOutboundMessageHandler() = default;
|
|
|
|
virtual bool
|
|
QueueMessage(const RouterID& remote, const ILinkMessage& msg, SendStatusHandler callback) = 0;
|
|
|
|
virtual void
|
|
Tick() = 0;
|
|
|
|
virtual void
|
|
RemovePath(const PathID_t& pathid) = 0;
|
|
|
|
virtual util::StatusObject
|
|
ExtractStatus() const = 0;
|
|
};
|
|
|
|
} // namespace llarp
|