Initial implementation of asmap health check
This commit is contained in:
33
src/net.cpp
33
src/net.cpp
@@ -50,6 +50,11 @@ extern int32_t HUSH_TESTNODE;
|
||||
// Satoshi originally used 10 seconds(!), did they know something Peter Wuille didn't?
|
||||
#define DUMP_ADDRESSES_INTERVAL 300
|
||||
|
||||
// Run asmap health check every 24hr by default
|
||||
#define ASMAP_HEALTHCHECK_INTERVAL 24*60*60
|
||||
// Uncomment to Use a 60s interval for debugging
|
||||
//#define ASMAP_HEALTHCHECK_INTERVAL 60
|
||||
|
||||
// This is every 2 blocks, on avg, on HUSH3
|
||||
#define DUMP_ZINDEX_INTERVAL 150
|
||||
|
||||
@@ -1648,6 +1653,26 @@ int64_t PoissonNextSend(int64_t now, int average_interval_seconds)
|
||||
return now + (int64_t)(log1p(GetRand(1ULL << 48) * -0.0000000000000035527136788 /* -1/2^48 */) * average_interval_seconds * -1000000.0 + 0.5);
|
||||
}
|
||||
|
||||
void ASMapHealthCheck() {
|
||||
std::set<uint32_t> clearnet_asns{};
|
||||
int unmapped_count{0};
|
||||
LOCK(cs_vNodes);
|
||||
|
||||
// TODO: skip onion/i2p nodes as they have no ASN
|
||||
for (const auto& pnode : vNodes) {
|
||||
uint32_t asn = pnode->addr.GetMappedAS(addrman.m_asmap);
|
||||
if (asn == 0) {
|
||||
++unmapped_count;
|
||||
continue;
|
||||
}
|
||||
clearnet_asns.insert(asn);
|
||||
}
|
||||
|
||||
LogPrintf("ASMap Health Check: %i clearnet peers are mapped to %i ASNs with %i peers being unmapped\n", vNodes.size(), clearnet_asns.size(), unmapped_count);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ThreadOpenConnections()
|
||||
{
|
||||
// Connect to specific addresses
|
||||
@@ -1753,7 +1778,7 @@ void ThreadOpenConnections()
|
||||
int64_t nNow = GetTime();
|
||||
int nTries = 0;
|
||||
|
||||
LogPrint("net", "Resolving addrman collisions\n");
|
||||
LogPrint("net", "Resolving addrman collisions\n");
|
||||
addrman.ResolveCollisions();
|
||||
|
||||
while (true) {
|
||||
@@ -1823,6 +1848,8 @@ void ThreadOpenConnections()
|
||||
OpenNetworkConnection(addrConnect,/*failures,*/ &grant, NULL, false, fFeeler);
|
||||
}
|
||||
}
|
||||
// Do a health check now that we hopefully have peers
|
||||
ASMapHealthCheck();
|
||||
}
|
||||
|
||||
void ThreadOpenAddedConnections()
|
||||
@@ -2378,7 +2405,11 @@ void StartNode(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||
scheduler.scheduleEvery(&DumpZindexStats, DUMP_ZINDEX_INTERVAL);
|
||||
}
|
||||
|
||||
// Look for ~/.hush/AC_NAME/plz_stop
|
||||
scheduler.scheduleEvery(&CheckIfWeShouldStop, CHECK_PLZ_STOP_INTERVAL);
|
||||
|
||||
// Schedule ASMap Health check to run regularly
|
||||
scheduler.scheduleEvery(&ASMapHealthCheck, ASMAP_HEALTHCHECK_INTERVAL);
|
||||
}
|
||||
|
||||
bool StopNode()
|
||||
|
||||
Reference in New Issue
Block a user