mirror of https://github.com/oxen-io/lokinet
tweaks
This commit is contained in:
parent
c23498925c
commit
965b0957ee
|
@ -345,7 +345,7 @@ namespace llarp
|
|||
static constexpr llarp_time_t MaxBuildInterval = 30 * 1000;
|
||||
buildIntervalLimit =
|
||||
std::min(1000 + buildIntervalLimit, MaxBuildInterval);
|
||||
// router->routerProfiling().MarkPathFail(p);
|
||||
router->routerProfiling().MarkPathFail(p);
|
||||
PathSet::HandlePathBuildTimeout(p);
|
||||
}
|
||||
|
||||
|
|
|
@ -165,6 +165,12 @@ namespace llarp
|
|||
HandleDHTLookupForExplore(RouterID remote,
|
||||
const std::vector< RouterContact > &results) = 0;
|
||||
|
||||
/// lookup router by pubkey
|
||||
/// if we are a service node this is done direct otherwise it's done via
|
||||
/// path
|
||||
virtual void
|
||||
LookupRouter(RouterID remote) = 0;
|
||||
|
||||
/// check if newRc matches oldRC and update local rc for this remote contact
|
||||
/// if valid
|
||||
/// returns true on valid and updated
|
||||
|
|
|
@ -1027,6 +1027,23 @@ namespace llarp
|
|||
this, router, std::placeholders::_1));
|
||||
}
|
||||
|
||||
void
|
||||
Router::LookupRouter(RouterID remote)
|
||||
{
|
||||
if(IsServiceNode())
|
||||
{
|
||||
ServiceNodeLookupRouterWhenExpired(remote);
|
||||
return;
|
||||
}
|
||||
auto ep = hiddenServiceContext().getFirstEndpoint();
|
||||
if(ep == nullptr)
|
||||
{
|
||||
LogError("cannot lookup ", remote, " no service endpoints available");
|
||||
return;
|
||||
}
|
||||
ep->LookupRouterAnon(remote);
|
||||
}
|
||||
|
||||
void
|
||||
Router::Tick()
|
||||
{
|
||||
|
@ -1035,15 +1052,16 @@ namespace llarp
|
|||
|
||||
routerProfiling().Tick();
|
||||
|
||||
if(_rc.ExpiresSoon(now, randint() % 10000))
|
||||
{
|
||||
LogInfo("regenerating RC");
|
||||
if(!UpdateOurRC(false))
|
||||
LogError("Failed to update our RC");
|
||||
}
|
||||
|
||||
if(IsServiceNode())
|
||||
{
|
||||
if(_rc.ExpiresSoon(now, randint() % 10000)
|
||||
|| (now - _rc.last_updated) > rcRegenInterval)
|
||||
{
|
||||
LogInfo("regenerating RC");
|
||||
if(!UpdateOurRC(false))
|
||||
LogError("Failed to update our RC");
|
||||
}
|
||||
|
||||
// only do this as service node
|
||||
// client endpoints do this on their own
|
||||
nodedb()->visit([&](const RouterContact &rc) -> bool {
|
||||
|
@ -1053,9 +1071,18 @@ namespace llarp
|
|||
});
|
||||
}
|
||||
// kill dead nodes
|
||||
std::set< RouterID > removed;
|
||||
nodedb()->RemoveIf([&](const RouterContact &rc) -> bool {
|
||||
return routerProfiling().IsBad(rc.pubkey);
|
||||
if(!routerProfiling().IsBad(rc.pubkey))
|
||||
return false;
|
||||
removed.insert(rc.pubkey);
|
||||
return true;
|
||||
});
|
||||
|
||||
// request killed nodes 1 time
|
||||
for(const auto &pk : removed)
|
||||
LookupRouter(pk);
|
||||
|
||||
paths.TickPaths(now);
|
||||
paths.ExpirePaths(now);
|
||||
|
||||
|
|
|
@ -211,11 +211,14 @@ namespace llarp
|
|||
uint16_t m_OutboundPort = 0;
|
||||
|
||||
/// always maintain this many connections to other routers
|
||||
size_t minConnectedRouters = 3;
|
||||
size_t minConnectedRouters = 2;
|
||||
/// hard upperbound limit on the number of router to router connections
|
||||
size_t maxConnectedRouters = 2000;
|
||||
|
||||
size_t minRequiredRouters = 4;
|
||||
/// how often do we resign our RC? milliseconds.
|
||||
// TODO: make configurable
|
||||
llarp_time_t rcRegenInterval = 60 * 60 * 1000;
|
||||
|
||||
// should we be sending padded messages every interval?
|
||||
bool sendPadding = false;
|
||||
|
@ -428,6 +431,9 @@ namespace llarp
|
|||
void
|
||||
FlushOutboundFor(RouterID remote, ILinkLayer *chosen = nullptr);
|
||||
|
||||
void
|
||||
LookupRouter(RouterID remote) override;
|
||||
|
||||
/// manually discard all pending messages to remote router
|
||||
void
|
||||
DiscardOutboundFor(const RouterID &remote);
|
||||
|
|
Loading…
Reference in New Issue