TODO: Implement statistics collector and return a set of the most reliable nodes.
}
}
+void CAddrMan::GetOnlineAddr_(std::vector<CAddress> &vAddr)
+{
+ for (std::map<int, CAddrInfo>::const_iterator it = mapInfo.begin(); it != mapInfo.end(); it++)
+ {
+ CAddrInfo addr = it->second;
+ bool fCurrentlyOnline = (GetAdjustedTime() - addr.nTime < 24 * 60 * 60);
+ if (fCurrentlyOnline)
+ vAddr.push_back(addr);
+ }
+}
+
void CAddrMan::Connected_(const CService &addr, int64_t nTime)
{
CAddrInfo *pinfo = Find(addr);
// Select several addresses at once.
void GetAddr_(std::vector<CAddress> &vAddr);
+ void GetOnlineAddr_(std::vector<CAddress> &vAddr);
// Mark an entry as currently-connected-to.
void Connected_(const CService &addr, int64_t nTime);
return vAddr;
}
+ std::vector<CAddress> GetOnlineAddr()
+ {
+ Check();
+ std::vector<CAddress> vAddr;
+ {
+ LOCK(cs);
+ GetOnlineAddr_(vAddr);
+ }
+ Check();
+ return vAddr;
+ }
+
// Mark an entry as currently-connected-to.
void Connected(const CService &addr, int64_t nTime = GetAdjustedTime())
{
"getaddrmaninfo\n"
"Returns a dump of addrman data.");
- vector<CAddress> vAddr = addrman.GetAddr();
+ // Return a full list of "online" address items
+ vector<CAddress> vAddr = addrman.GetOnlineAddr();
Array ret;
BOOST_FOREACH(const CAddress &addr, vAddr) {
- // Don't return addresses older than nCutOff timestamp
- int64_t nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60);
-
- if (!addr.IsRoutable() || addr.IsLocal() || addr.nTime > nCutOff)
+ if (!addr.IsRoutable() || addr.IsLocal())
continue;
Object addrManItem;