Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/main.cpp
#include "bitcoin.h" | #include "bitcoin.h" | ||||
#include "clientversion.h" | |||||
#include "db.h" | #include "db.h" | ||||
#include "streams.h" | |||||
#include <algorithm> | #include <algorithm> | ||||
#include <atomic> | #include <atomic> | ||||
#include <cstdio> | #include <cstdio> | ||||
#include <cstdlib> | #include <cstdlib> | ||||
#include <getopt.h> | #include <getopt.h> | ||||
#include <pthread.h> | #include <pthread.h> | ||||
#include <signal.h> | #include <signal.h> | ||||
▲ Show 20 Lines • Show All 344 Lines • ▼ Show 20 Lines | do { | ||||
} | } | ||||
{ | { | ||||
std::vector<CAddrReport> v = db.GetAll(); | std::vector<CAddrReport> v = db.GetAll(); | ||||
sort(v.begin(), v.end(), StatCompare); | sort(v.begin(), v.end(), StatCompare); | ||||
FILE *f = fopen("dnsseed.dat.new", "w+"); | FILE *f = fopen("dnsseed.dat.new", "w+"); | ||||
if (f) { | if (f) { | ||||
{ | { | ||||
CAutoFile cf(f); | CAutoFile cf(f, SER_DISK, CLIENT_VERSION); | ||||
cf << db; | cf << db; | ||||
} | } | ||||
rename("dnsseed.dat.new", "dnsseed.dat"); | rename("dnsseed.dat.new", "dnsseed.dat"); | ||||
} | } | ||||
FILE *d = fopen("dnsseed.dump", "w"); | FILE *d = fopen("dnsseed.dump", "w"); | ||||
fprintf(d, "# address good " | fprintf(d, "# address good " | ||||
"lastSuccess %%(2h) %%(8h) %%(1d) %%(7d) " | "lastSuccess %%(2h) %%(8h) %%(1d) %%(7d) " | ||||
"%%(30d) blocks svcs version\n"); | "%%(30d) blocks svcs version\n"); | ||||
▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | extern "C" void *ThreadStats(void *) { | ||||
} while (1); | } while (1); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
static const std::string mainnet_seeds[] = { | static const std::string mainnet_seeds[] = { | ||||
"seed.bitcoinabc.org", "seed-abc.bitcoinforks.org", "seed.bitprim.org", | "seed.bitcoinabc.org", "seed-abc.bitcoinforks.org", "seed.bitprim.org", | ||||
"seed.deadalnix.me", "seeder.criptolayer.net", ""}; | "seed.deadalnix.me", "seeder.criptolayer.net", ""}; | ||||
static const std::string testnet_seeds[] = { | static const std::string testnet_seeds[] = { | ||||
"testnet-seed.bitcoinabc.org", | "testnet-seed.bitcoinabc.org", "testnet-seed-abc.bitcoinforks.org", | ||||
"testnet-seed-abc.bitcoinforks.org", | "testnet-seed.bitprim.org", "testnet-seed.deadalnix.me", | ||||
"testnet-seed.bitprim.org", | "testnet-seeder.criptolayer.net", ""}; | ||||
"testnet-seed.deadalnix.me", | |||||
"testnet-seeder.criptolayer.net", | |||||
""}; | |||||
static const std::string *seeds = mainnet_seeds; | static const std::string *seeds = mainnet_seeds; | ||||
extern "C" void *ThreadSeeder(void *) { | extern "C" void *ThreadSeeder(void *) { | ||||
if (!fTestNet) { | if (!fTestNet) { | ||||
db.Add(CService("kjy2eqzk4zwi5zd3.onion", 8333), true); | db.Add(CService("kjy2eqzk4zwi5zd3.onion", 8333), true); | ||||
} | } | ||||
do { | do { | ||||
for (int i = 0; seeds[i] != ""; i++) { | for (int i = 0; seeds[i] != ""; i++) { | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | int main(int argc, char **argv) { | ||||
} | } | ||||
if (fDNS && !opts.mbox) { | if (fDNS && !opts.mbox) { | ||||
fprintf(stderr, "No e-mail address set. Please use -m.\n"); | fprintf(stderr, "No e-mail address set. Please use -m.\n"); | ||||
exit(1); | exit(1); | ||||
} | } | ||||
FILE *f = fopen("dnsseed.dat", "r"); | FILE *f = fopen("dnsseed.dat", "r"); | ||||
if (f) { | if (f) { | ||||
printf("Loading dnsseed.dat..."); | printf("Loading dnsseed.dat..."); | ||||
CAutoFile cf(f); | CAutoFile cf(f, SER_DISK, CLIENT_VERSION); | ||||
cf >> db; | cf >> db; | ||||
if (opts.fWipeBan) db.banned.clear(); | if (opts.fWipeBan) db.banned.clear(); | ||||
if (opts.fWipeIgnore) db.ResetIgnores(); | if (opts.fWipeIgnore) db.ResetIgnores(); | ||||
printf("done\n"); | printf("done\n"); | ||||
} | } | ||||
pthread_t threadDns, threadSeed, threadDump, threadStats; | pthread_t threadDns, threadSeed, threadDump, threadStats; | ||||
if (fDNS) { | if (fDNS) { | ||||
printf("Starting %i DNS threads for %s on %s (port %i)...", | printf("Starting %i DNS threads for %s on %s (port %i)...", | ||||
Show All 29 Lines |