mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 14:08:40 +01:00
net: Add continuous ASMap health check logging
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include <netgroup.h>
|
||||
|
||||
#include <hash.h>
|
||||
#include <logging.h>
|
||||
#include <util/asmap.h>
|
||||
|
||||
uint256 NetGroupManager::GetAsmapChecksum() const
|
||||
@@ -109,3 +110,23 @@ uint32_t NetGroupManager::GetMappedAS(const CNetAddr& address) const
|
||||
uint32_t mapped_as = Interpret(m_asmap, ip_bits);
|
||||
return mapped_as;
|
||||
}
|
||||
|
||||
void NetGroupManager::ASMapHealthCheck(const std::vector<CNetAddr>& clearnet_addrs) const {
|
||||
std::set<uint32_t> clearnet_asns{};
|
||||
int unmapped_count{0};
|
||||
|
||||
for (const auto& addr : clearnet_addrs) {
|
||||
uint32_t asn = GetMappedAS(addr);
|
||||
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", clearnet_addrs.size(), clearnet_asns.size(), unmapped_count);
|
||||
}
|
||||
|
||||
bool NetGroupManager::UsingASMap() const {
|
||||
return m_asmap.size() > 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user