#include #include "bitcoin.h" #include "db.h" #define NTHREADS 32 using namespace std; extern "C" { #include "dns.h" } CAddrDb db; extern "C" void* ThreadCrawler(void* data) { do { CIPPort ip; int wait = 5; if (!db.Get(ip, wait)) { wait *= 1000; wait += rand() % (500 * NTHREADS); Sleep(wait); continue; } int ban = 0; vector addr; int clientV = 0; bool ret = TestNode(ip,ban,clientV,addr); db.Add(addr); if (ret) { db.Good(ip, clientV); } else { db.Bad(ip, ban); } } while(1); } extern "C" int GetIPList(struct in_addr *addr, int max, int ipv4only) { set ips; db.GetIPs(ips, max, ipv4only); int n = 0; for (set::iterator it = ips.begin(); it != ips.end(); it++) { if ((*it).GetInAddr(&addr[n])) n++; } // permute list for (int i=0; i ips; LookupHost(seeds[i].c_str(), ips); for (vector::iterator it = ips.begin(); it != ips.end(); it++) { db.Add(CIPPort(*it, 8333), true); } } Sleep(1800000); } while(1); } int main(void) { FILE *f = fopen("dnsseed.dat","r"); if (f) { CAutoFile cf(f); cf >> db; } pthread_t thread[NTHREADS+4]; for (int i=0; i