This commit is contained in:
Ryan Tharp 2019-01-29 12:48:30 +00:00
commit 1a62382ce7
2 changed files with 17 additions and 11 deletions

View File

@ -434,11 +434,16 @@ llarp_nodedb::select_random_hop(const llarp::RouterContact &prev,
do do
{ {
auto itr = entries.begin(); auto itr = entries.begin();
std::advance(itr, llarp::randint() % sz);
if(itr == entries.end())
{
--tries;
continue;
}
if(prev.pubkey == itr->second.pubkey) if(prev.pubkey == itr->second.pubkey)
{ {
if(tries--) --tries;
continue; continue;
return false;
} }
if(itr->second.addrs.size() && !itr->second.IsExpired(now)) if(itr->second.addrs.size() && !itr->second.IsExpired(now))
{ {

View File

@ -682,6 +682,7 @@ namespace llarp
if(rotateKeys) if(rotateKeys)
{ {
encryption = nextOnionKey; encryption = nextOnionKey;
}
// propagate RC by renegotiating sessions // propagate RC by renegotiating sessions
ForEachPeer([](llarp::ILinkSession *s) { ForEachPeer([](llarp::ILinkSession *s) {
if(s->RenegotiateSession()) if(s->RenegotiateSession())
@ -689,7 +690,7 @@ namespace llarp
else else
llarp::LogWarn("failed to renegotiate session"); llarp::LogWarn("failed to renegotiate session");
}); });
}
// TODO: do this async // TODO: do this async
return SaveRC(); return SaveRC();
} // namespace llarp } // namespace llarp
@ -737,7 +738,7 @@ namespace llarp
if(_rc.ExpiresSoon(now, llarp::randint() % 10000)) if(_rc.ExpiresSoon(now, llarp::randint() % 10000))
{ {
llarp::LogInfo("regenerating RC"); llarp::LogInfo("regenerating RC");
if(!UpdateOurRC(IsServiceNode())) if(!UpdateOurRC(false))
llarp::LogError("Failed to update our RC"); llarp::LogError("Failed to update our RC");
} }