diff --git a/llarp/messages/relay_commit.cpp b/llarp/messages/relay_commit.cpp index 308c5d54a..af1540ced 100644 --- a/llarp/messages/relay_commit.cpp +++ b/llarp/messages/relay_commit.cpp @@ -281,7 +281,7 @@ namespace llarp using namespace std::placeholders; if(self->record.work && self->record.work->IsValid( - std::bind(&Crypto::shorthash, crypto, _1, _2), now)) + std::bind(&Crypto::shorthash, crypto, _1, _2), now)) { llarp::LogDebug("LRCM extended lifetime by ", self->record.work->extendedLifetime, " seconds for ", diff --git a/llarp/nodedb.cpp b/llarp/nodedb.cpp index 48cc6912e..c52707146 100644 --- a/llarp/nodedb.cpp +++ b/llarp/nodedb.cpp @@ -18,13 +18,16 @@ static const std::string RC_FILE_EXT = ".signed"; bool llarp_nodedb::Remove(const llarp::RouterID &pk) { - llarp::util::Lock lock(&access); - auto itr = entries.find(pk); - if(itr == entries.end()) + bool removed = false; + RemoveIf([&](const llarp::RouterContact &rc) -> bool { + if(rc.pubkey == pk) + { + removed = true; + return true; + } return false; - entries.erase(itr); - fs::remove(fs::path(getRCFilePath(pk))); - return true; + }); + return removed; } void diff --git a/llarp/router/router.cpp b/llarp/router/router.cpp index 4e43b6c68..48705fd6c 100644 --- a/llarp/router/router.cpp +++ b/llarp/router/router.cpp @@ -71,15 +71,16 @@ struct TryConnectJob void AttemptTimedout() { - router->routerProfiling().MarkTimeout(rc.pubkey); if(ShouldRetry()) { Attempt(); return; } + router->routerProfiling().MarkTimeout(rc.pubkey); if(router->routerProfiling().IsBad(rc.pubkey)) { - router->nodedb()->Remove(rc.pubkey); + if(!router->IsBootstrapNode(rc.pubkey)) + router->nodedb()->Remove(rc.pubkey); } // delete this router->pendingEstablishJobs.erase(rc.pubkey); @@ -1102,7 +1103,7 @@ namespace llarp if(!routerProfiling().IsBad(rc.pubkey)) return false; routerProfiling().ClearProfile(rc.pubkey); - return true; + return !IsBootstrapNode(rc.pubkey); }); } paths.TickPaths(now); @@ -1690,12 +1691,8 @@ namespace llarp && !(self->HasSessionTo(other.pubkey) || self->HasPendingConnectJob(other.pubkey))) { - for(const auto &rc : self->bootstrapRCList) - { - if(rc.pubkey == other.pubkey) - return want > 0; - } - self->TryConnectAsync(other, 5); + if(!self->IsBootstrapNode(other.pubkey)) + self->TryConnectAsync(other, 5); --want; } return want > 0; diff --git a/llarp/util/bencode.cpp b/llarp/util/bencode.cpp index 991c53df6..8c4da586b 100644 --- a/llarp/util/bencode.cpp +++ b/llarp/util/bencode.cpp @@ -77,7 +77,8 @@ bencode_write_uint64(llarp_buffer_t* buff, uint64_t i) { // NetBSDs also do this shit in long mode, wouldn't be surprised // if all the BSDs do by default -#if !defined(__LP64__) || (__APPLE__ && __MACH__) || (__NetBSD__) || (__OpenBSD__) +#if !defined(__LP64__) || (__APPLE__ && __MACH__) || (__NetBSD__) \ + || (__OpenBSD__) if(!buff->writef("i%llu", i)) #else if(!buff->writef("i%lu", i)) diff --git a/llarp/util/threadpool.h b/llarp/util/threadpool.h index 463ef0994..b425890ee 100644 --- a/llarp/util/threadpool.h +++ b/llarp/util/threadpool.h @@ -16,8 +16,8 @@ struct llarp_threadpool std::queue< std::function< void(void) > > jobs GUARDED_BY(m_access); llarp_threadpool(int workers, const char *name) - : impl(std::make_unique< llarp::thread::ThreadPool >(workers, - workers * 128)) + : impl( + std::make_unique< llarp::thread::ThreadPool >(workers, workers * 128)) { (void)name; }