Browse Source

optimizations until we grow older and bigger: getaddr always and return all known ips per dns thread.

+ enable some debug printfs
pull/1/head
Miguel Freitas 11 years ago
parent
commit
02d90b2097
  1. 6
      bitcoin.cpp
  2. 4
      db.cpp
  3. 8
      main.cpp

6
bitcoin.cpp

@ -133,19 +133,19 @@ class CNode {
if (strCommand == "addr" && vAddr) { if (strCommand == "addr" && vAddr) {
vector<CAddress> vAddrNew; vector<CAddress> vAddrNew;
vRecv >> vAddrNew; vRecv >> vAddrNew;
// printf("%s: got %i addresses\n", ToString(you).c_str(), (int)vAddrNew.size()); printf("%s: got %i addresses\n", ToString(you).c_str(), (int)vAddrNew.size());
int64 now = time(NULL); int64 now = time(NULL);
vector<CAddress>::iterator it = vAddrNew.begin(); vector<CAddress>::iterator it = vAddrNew.begin();
if (doneAfter == 0 || doneAfter > now + 1) doneAfter = now + 1; if (doneAfter == 0 || doneAfter > now + 1) doneAfter = now + 1;
while (it != vAddrNew.end()) { while (it != vAddrNew.end()) {
CAddress &addr = *it; CAddress &addr = *it;
// printf("%s: got address %s\n", ToString(you).c_str(), addr.ToString().c_str(), (int)(vAddr->size())); printf("%s: got address %s\n", ToString(you).c_str(), addr.ToString().c_str(), (int)(vAddr->size()));
it++; it++;
if (addr.nTime <= 100000000 || addr.nTime > now + 600) if (addr.nTime <= 100000000 || addr.nTime > now + 600)
addr.nTime = now - 5 * 86400; addr.nTime = now - 5 * 86400;
if (addr.nTime > now - 604800) if (addr.nTime > now - 604800)
vAddr->push_back(addr); vAddr->push_back(addr);
// printf("%s: added address %s (#%i)\n", ToString(you).c_str(), addr.ToString().c_str(), (int)(vAddr->size())); printf("%s: added address %s (#%i)\n", ToString(you).c_str(), addr.ToString().c_str(), (int)(vAddr->size()));
if (vAddr->size() > 1000) {doneAfter = 1; return true; } if (vAddr->size() > 1000) {doneAfter = 1; return true; }
} }
return false; return false;

4
db.cpp

@ -180,8 +180,8 @@ void CAddrDb::GetIPs_(set<CNetAddr>& ips, int max, const bool* nets) {
} }
return; return;
} }
if (max > goodId.size() / 2) if (max > goodId.size() / 1) // [MF] /2
max = goodId.size() / 2; max = goodId.size() / 1; // [MF] /2
if (max < 1) if (max < 1)
max = 1; max = 1;
int low = *goodId.begin(); int low = *goodId.begin();

8
main.cpp

@ -143,7 +143,8 @@ extern "C" void* ThreadCrawler(void* data) {
res.nClientV = 0; res.nClientV = 0;
res.nHeight = 0; res.nHeight = 0;
res.strClientV = ""; res.strClientV = "";
bool getaddr = res.ourLastSuccess + 604800 < now; //bool getaddr = res.ourLastSuccess + 604800 < now;
bool getaddr = true; // [MF] always getaddr
res.fGood = TestNode(res.service,res.nBanTime,res.nClientV,res.strClientV,res.nHeight,getaddr ? &addr : NULL); res.fGood = TestNode(res.service,res.nBanTime,res.nClientV,res.strClientV,res.nHeight,getaddr ? &addr : NULL);
} }
db.ResultMany(ips); db.ResultMany(ips);
@ -232,6 +233,7 @@ extern "C" int GetIPList(void *data, addr_t* addr, int max, int ipv4, int ipv6)
thread->cacheHit(); thread->cacheHit();
unsigned int size = thread->cache.size(); unsigned int size = thread->cache.size();
unsigned int maxmax = (ipv4 ? thread->nIPv4 : 0) + (ipv6 ? thread->nIPv6 : 0); unsigned int maxmax = (ipv4 ? thread->nIPv4 : 0) + (ipv6 ? thread->nIPv6 : 0);
if (max > size) if (max > size)
max = size; max = size;
if (max > maxmax) if (max > maxmax)
@ -320,6 +322,7 @@ extern "C" void* ThreadStats(void*) {
strftime(c, 256, "[%y-%m-%d %H:%M:%S]", tmp); strftime(c, 256, "[%y-%m-%d %H:%M:%S]", tmp);
CAddrDbStats stats; CAddrDbStats stats;
db.GetStats(stats); db.GetStats(stats);
/*
if (first) if (first)
{ {
first = false; first = false;
@ -328,13 +331,14 @@ extern "C" void* ThreadStats(void*) {
else else
printf("\x1b[2K\x1b[u"); printf("\x1b[2K\x1b[u");
printf("\x1b[s"); printf("\x1b[s");
*/
uint64_t requests = 0; uint64_t requests = 0;
uint64_t queries = 0; uint64_t queries = 0;
for (unsigned int i=0; i<dnsThread.size(); i++) { for (unsigned int i=0; i<dnsThread.size(); i++) {
requests += dnsThread[i]->dns_opt.nRequests; requests += dnsThread[i]->dns_opt.nRequests;
queries += dnsThread[i]->dbQueries; queries += dnsThread[i]->dbQueries;
} }
printf("%s %i/%i available (%i tried in %is, %i new, %i active), %i banned; %llu DNS requests, %llu db queries", c, stats.nGood, stats.nAvail, stats.nTracked, stats.nAge, stats.nNew, stats.nAvail - stats.nTracked - stats.nNew, stats.nBanned, (unsigned long long)requests, (unsigned long long)queries); printf("%s %i/%i available (%i tried in %is, %i new, %i active), %i banned; %llu DNS requests, %llu db queries\n", c, stats.nGood, stats.nAvail, stats.nTracked, stats.nAge, stats.nNew, stats.nAvail - stats.nTracked - stats.nNew, stats.nBanned, (unsigned long long)requests, (unsigned long long)queries);
Sleep(1000); Sleep(1000);
} while(1); } while(1);
} }

Loading…
Cancel
Save