mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-17 15:25:35 +00:00
0fe7153f6e
- Replace m_FlushWakeup with a call to the router's god mode pump method. m_FlushWakeup apparently isn't enough to get things out, and we can end up with incoming packets that don't get properly handled right away without it. - The shared_ptr around the ihophandler queues isn't needed and is just adding a layer of obfuscation; instead just exchange the list directly into the lambda. - Use std::exchange rather than swap - A couple other small code cleanups.
40 lines
1.0 KiB
C++
40 lines
1.0 KiB
C++
#include "ihophandler.hpp"
|
|
#include <llarp/router/abstractrouter.hpp>
|
|
|
|
namespace llarp
|
|
{
|
|
namespace path
|
|
{
|
|
// handle data in upstream direction
|
|
bool
|
|
IHopHandler::HandleUpstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter* r)
|
|
{
|
|
auto& pkt = m_UpstreamQueue.emplace_back();
|
|
pkt.first.resize(X.sz);
|
|
std::copy_n(X.base, X.sz, pkt.first.begin());
|
|
pkt.second = Y;
|
|
r->TriggerPump();
|
|
return true;
|
|
}
|
|
|
|
// handle data in downstream direction
|
|
bool
|
|
IHopHandler::HandleDownstream(const llarp_buffer_t& X, const TunnelNonce& Y, AbstractRouter* r)
|
|
{
|
|
auto& pkt = m_DownstreamQueue.emplace_back();
|
|
pkt.first.resize(X.sz);
|
|
std::copy_n(X.base, X.sz, pkt.first.begin());
|
|
pkt.second = Y;
|
|
r->TriggerPump();
|
|
return true;
|
|
}
|
|
|
|
void
|
|
IHopHandler::DecayFilters(llarp_time_t now)
|
|
{
|
|
m_UpstreamReplayFilter.Decay(now);
|
|
m_DownstreamReplayFilter.Decay(now);
|
|
}
|
|
} // namespace path
|
|
} // namespace llarp
|