relays do profiling and not hand out "shit" routers in explore

pull/1020/head
Jeff Becker 4 years ago
parent c1ad5f955a
commit c3b14b32b4
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -671,7 +671,11 @@ namespace llarp
}
for(const auto& f : foundRouters)
{
closer.emplace_back(f.as_array());
const RouterID r = f;
// discard shit routers
if(router->routerProfiling().IsBadForConnect(r))
continue;
closer.emplace_back(r);
}
llarp::LogDebug("Gave ", closer.size(), " routers for exploration");
reply.emplace_back(new GotRouterMessage(txid, closer, false));

@ -151,7 +151,7 @@ namespace llarp
void
OutboundSessionMaker::Init(
ILinkManager *linkManager, I_RCLookupHandler *rcLookup,
std::shared_ptr< Logic > logic, llarp_nodedb *nodedb,
Profiling *profiler, std::shared_ptr< Logic > logic, llarp_nodedb *nodedb,
std::shared_ptr< llarp::thread::ThreadPool > threadpool)
{
_linkManager = linkManager;
@ -159,6 +159,7 @@ namespace llarp
_logic = logic;
_nodedb = nodedb;
_threadpool = threadpool;
_profiler = profiler;
}
void
@ -307,7 +308,15 @@ namespace llarp
{
util::Lock l(&_mutex);
// TODO: Router profiling stuff
if(type == SessionResult::Establish)
{
_profiler->MarkConnectSuccess(router);
}
else
{
// TODO: add non timeout related fail case
_profiler->MarkConnectTimeout(router);
}
auto itr = pendingCallbacks.find(router);

@ -58,7 +58,8 @@ namespace llarp
void
Init(ILinkManager *linkManager, I_RCLookupHandler *rcLookup,
std::shared_ptr< Logic > logic, llarp_nodedb *nodedb,
Profiling *profiler, std::shared_ptr< Logic > logic,
llarp_nodedb *nodedb,
std::shared_ptr< llarp::thread::ThreadPool > threadpool);
void
@ -109,10 +110,11 @@ namespace llarp
std::unordered_map< RouterID, CallbacksQueue, RouterID::Hash >
pendingCallbacks GUARDED_BY(_mutex);
ILinkManager *_linkManager;
I_RCLookupHandler *_rcLookup;
ILinkManager *_linkManager = nullptr;
I_RCLookupHandler *_rcLookup = nullptr;
Profiling *_profiler = nullptr;
llarp_nodedb *_nodedb = nullptr;
std::shared_ptr< Logic > _logic;
llarp_nodedb *_nodedb;
std::shared_ptr< llarp::thread::ThreadPool > _threadpool;
RouterID us;
};

@ -492,8 +492,9 @@ namespace llarp
// Init components after relevant config settings loaded
_outboundMessageHandler.Init(&_linkManager, _logic);
_outboundSessionMaker.Init(&_linkManager, &_rcLookupHandler, _logic,
_nodedb, threadpool());
_outboundSessionMaker.Init(&_linkManager, &_rcLookupHandler,
&_routerProfiling, _logic, _nodedb,
threadpool());
_linkManager.Init(&_outboundSessionMaker);
_rcLookupHandler.Init(_dht, _nodedb, threadpool(), &_linkManager,
&_hiddenServiceContext, strictConnectPubkeys,
@ -551,20 +552,14 @@ namespace llarp
// set network config
netConfig = conf->network.netConfig();
if(not IsServiceNode())
routerProfiling().Enable();
// Network config
if(conf->network.enableProfiling().has_value())
{
if(conf->network.enableProfiling().value())
{
routerProfiling().Enable();
LogInfo("router profiling explicitly enabled");
}
else
if(not conf->network.enableProfiling().value())
{
routerProfiling().Disable();
LogInfo("router profiling explicitly disabled");
LogWarn("router profiling explicitly disabled");
}
}

Loading…
Cancel
Save