|
|
|
@ -172,26 +172,24 @@ namespace llarp
|
|
|
|
|
IHopHandler*
|
|
|
|
|
PathContext::GetByUpstream(const RouterID& remote, const PathID_t& id)
|
|
|
|
|
{
|
|
|
|
|
auto own = MapGet(
|
|
|
|
|
m_OurPaths, id,
|
|
|
|
|
[](__attribute__((unused)) const PathSet* s) -> bool {
|
|
|
|
|
// TODO: is this right?
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
[remote, id](PathSet* p) -> IHopHandler* {
|
|
|
|
|
return p->GetByUpstream(remote, id);
|
|
|
|
|
});
|
|
|
|
|
auto own = MapGet(m_OurPaths, id,
|
|
|
|
|
[](__attribute__((unused)) const PathSet* s) -> bool {
|
|
|
|
|
// TODO: is this right?
|
|
|
|
|
return true;
|
|
|
|
|
},
|
|
|
|
|
[remote, id](PathSet* p) -> IHopHandler* {
|
|
|
|
|
return p->GetByUpstream(remote, id);
|
|
|
|
|
});
|
|
|
|
|
if(own)
|
|
|
|
|
return own;
|
|
|
|
|
|
|
|
|
|
return MapGet(
|
|
|
|
|
m_TransitPaths, id,
|
|
|
|
|
[remote](const std::shared_ptr< TransitHop >& hop) -> bool {
|
|
|
|
|
return hop->info.upstream == remote;
|
|
|
|
|
},
|
|
|
|
|
[](const std::shared_ptr< TransitHop >& h) -> IHopHandler* {
|
|
|
|
|
return h.get();
|
|
|
|
|
});
|
|
|
|
|
return MapGet(m_TransitPaths, id,
|
|
|
|
|
[remote](const std::shared_ptr< TransitHop >& hop) -> bool {
|
|
|
|
|
return hop->info.upstream == remote;
|
|
|
|
|
},
|
|
|
|
|
[](const std::shared_ptr< TransitHop >& h) -> IHopHandler* {
|
|
|
|
|
return h.get();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
@ -208,14 +206,13 @@ namespace llarp
|
|
|
|
|
IHopHandler*
|
|
|
|
|
PathContext::GetByDownstream(const RouterID& remote, const PathID_t& id)
|
|
|
|
|
{
|
|
|
|
|
return MapGet(
|
|
|
|
|
m_TransitPaths, id,
|
|
|
|
|
[remote](const std::shared_ptr< TransitHop >& hop) -> bool {
|
|
|
|
|
return hop->info.downstream == remote;
|
|
|
|
|
},
|
|
|
|
|
[](const std::shared_ptr< TransitHop >& h) -> IHopHandler* {
|
|
|
|
|
return h.get();
|
|
|
|
|
});
|
|
|
|
|
return MapGet(m_TransitPaths, id,
|
|
|
|
|
[remote](const std::shared_ptr< TransitHop >& hop) -> bool {
|
|
|
|
|
return hop->info.downstream == remote;
|
|
|
|
|
},
|
|
|
|
|
[](const std::shared_ptr< TransitHop >& h) -> IHopHandler* {
|
|
|
|
|
return h.get();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PathSet*
|
|
|
|
@ -440,6 +437,13 @@ namespace llarp
|
|
|
|
|
return intro.latency > 0 && _status == ePathEstablished;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
|
Path::IsEndpoint(const RouterID& r, const PathID_t& id) const
|
|
|
|
|
{
|
|
|
|
|
return hops[hops.size() - 1].rc.pubkey == r
|
|
|
|
|
&& hops[hops.size() - 1].txID == id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RouterID
|
|
|
|
|
Path::Upstream() const
|
|
|
|
|
{
|
|
|
|
|