Changeset View
Changeset View
Standalone View
Standalone View
src/seeder/main.cpp
Show First 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | int ParseCommandLine(int argc, char **argv) { | ||||
mbox = gArgs.GetArg("-mbox", DEFAULT_EMAIL); | mbox = gArgs.GetArg("-mbox", DEFAULT_EMAIL); | ||||
ns = gArgs.GetArg("-ns", DEFAULT_NAMESERVER); | ns = gArgs.GetArg("-ns", DEFAULT_NAMESERVER); | ||||
host = gArgs.GetArg("-host", DEFAULT_HOST); | host = gArgs.GetArg("-host", DEFAULT_HOST); | ||||
tor = gArgs.GetArg("-onion", DEFAULT_TOR_PROXY); | tor = gArgs.GetArg("-onion", DEFAULT_TOR_PROXY); | ||||
ipv4_proxy = gArgs.GetArg("-proxyipv4", DEFAULT_IPV4_PROXY); | ipv4_proxy = gArgs.GetArg("-proxyipv4", DEFAULT_IPV4_PROXY); | ||||
ipv6_proxy = gArgs.GetArg("-proxyipv6", DEFAULT_IPV6_PROXY); | ipv6_proxy = gArgs.GetArg("-proxyipv6", DEFAULT_IPV6_PROXY); | ||||
SelectParams(gArgs.GetChainName()); | SelectParams(gArgs.GetChainName()); | ||||
if (!gArgs.IsArgSet("-datadir")) { | |||||
deadalnix: The diff still mention seederdir. | |||||
fs::path path = GetDefaultDataDir() / "seeder"; | |||||
deadalnixUnsubmitted Not Done Inline ActionsWouldn't it be preferable to always append a seedersubfolder to the datadir? deadalnix: Wouldn't it be preferable to always append a seedersubfolder to the datadir? | |||||
nakihitoAuthorUnsubmitted Done Inline ActionsI do not think so. The help text says that the option specifies the directory that is read from and/or written to. Right now, the option is flexible in that a user can specify any directory and the seeder will read and write from there. This gives users more control if, for example, someone wants to keep the seeder directory separate from the regular node directory. If a user specifies -datadir=~/.seeder/ for example, it is expected that reads from and writes to the specified directory ~/.seeder/ and not ~/.seeder/seeder/. This also more closely matches the behavior of the node software's -datadir option. nakihito: I do not think so. The help text says that the option specifies the directory that is read… | |||||
gArgs.ForceSetArg("-datadir", path.string()); | |||||
fs::create_directories(path); | |||||
} | |||||
if (!CheckDataDirOption()) { | |||||
tfm::format(std::cerr, | |||||
"Specified data directory \"%s\" does not exist.\n", | |||||
gArgs.GetArg("-datadir", "")); | |||||
return EXIT_FAILURE; | |||||
} | |||||
// Warn about relative -datadir path | |||||
if (gArgs.IsArgSet("-datadir") && | |||||
!fs::path(gArgs.GetArg("-datadir", "")).is_absolute()) { | |||||
tfm::format( | |||||
std::cout, | |||||
"Warning: relative datadir option '%s' specified, which will " | |||||
"be interpreted relative to the current working directory " | |||||
"'%s'. This is fragile, because if the seeder is started in " | |||||
"the future from a different location, it will be unable to " | |||||
"locate the current data files.\n", | |||||
gArgs.GetArg("-datadir", ""), fs::current_path().string()); | |||||
} | |||||
if (gArgs.IsArgSet("-filter")) { | if (gArgs.IsArgSet("-filter")) { | ||||
// Parse whitelist additions | // Parse whitelist additions | ||||
std::string flagString = gArgs.GetArg("-filter", ""); | std::string flagString = gArgs.GetArg("-filter", ""); | ||||
size_t flagstartpos = 0; | size_t flagstartpos = 0; | ||||
while (flagstartpos < flagString.size()) { | while (flagstartpos < flagString.size()) { | ||||
size_t flagendpos = flagString.find_first_of(',', flagstartpos); | size_t flagendpos = flagString.find_first_of(',', flagstartpos); | ||||
uint64_t flag = atoi64(flagString.substr( | uint64_t flag = atoi64(flagString.substr( | ||||
flagstartpos, (flagendpos - flagstartpos))); | flagstartpos, (flagendpos - flagstartpos))); | ||||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | void SetupSeederArgs() { | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ||||
gArgs.AddArg("-wipeban", "Wipe list of banned nodes", | gArgs.AddArg("-wipeban", "Wipe list of banned nodes", | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||
gArgs.AddArg("-wipeignore", "Wipe list of ignored nodes", | gArgs.AddArg("-wipeignore", "Wipe list of ignored nodes", | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION); | ||||
gArgs.AddArg("-help-debug", | gArgs.AddArg("-help-debug", | ||||
"Show all debugging options (usage: --help -help-debug)", | "Show all debugging options (usage: --help -help-debug)", | ||||
ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); | ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); | ||||
gArgs.AddArg( | |||||
"-datadir=<dir>", | |||||
"Specifies the directory that the seeder reads from and writes to.", | |||||
ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | |||||
SetupChainParamsBaseOptions(); | SetupChainParamsBaseOptions(); | ||||
gArgs.AddArg("-help", "", ArgsManager::ALLOW_ANY, | gArgs.AddArg("-help", "", ArgsManager::ALLOW_ANY, | ||||
OptionsCategory::HIDDEN); | OptionsCategory::HIDDEN); | ||||
gArgs.AddArg("-h", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); | gArgs.AddArg("-h", "", ArgsManager::ALLOW_ANY, OptionsCategory::HIDDEN); | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 212 Lines • ▼ Show 20 Lines | do { | ||||
Sleep(100000 << count); | Sleep(100000 << count); | ||||
if (count < 5) { | if (count < 5) { | ||||
count++; | count++; | ||||
} | } | ||||
{ | { | ||||
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 = fsbridge::fopen("dnsseed.dat.new", "w+"); | FILE *f = fsbridge::fopen(GetDataDir() / "dnsseed.dat.new", "w+"); | ||||
if (f) { | if (f) { | ||||
{ | { | ||||
CAutoFile cf(f, SER_DISK, CLIENT_VERSION); | CAutoFile cf(f, SER_DISK, CLIENT_VERSION); | ||||
cf << db; | cf << db; | ||||
} | } | ||||
rename("dnsseed.dat.new", "dnsseed.dat"); | rename(GetDataDir() / "dnsseed.dat.new", | ||||
GetDataDir() / "dnsseed.dat"); | |||||
} | } | ||||
fsbridge::ofstream d{"dnsseed.dump"}; | fsbridge::ofstream d{GetDataDir() / "dnsseed.dump"}; | ||||
tfm::format( | tfm::format( | ||||
d, "# address good " | d, "# address good " | ||||
"lastSuccess %%(2h) %%(8h) %%(1d) %%(7d) " | "lastSuccess %%(2h) %%(8h) %%(1d) %%(7d) " | ||||
"%%(30d) blocks svcs version\n"); | "%%(30d) blocks svcs version\n"); | ||||
double stat[5] = {0, 0, 0, 0, 0}; | double stat[5] = {0, 0, 0, 0, 0}; | ||||
for (CAddrReport rep : v) { | for (CAddrReport rep : v) { | ||||
tfm::format( | tfm::format( | ||||
d, | d, | ||||
"%-47s %4d %11" PRId64 | "%-47s %4d %11" PRId64 | ||||
" %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6i %08" PRIx64 | " %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6.2f%% %6i %08" PRIx64 | ||||
" %5i \"%s\"\n", | " %5i \"%s\"\n", | ||||
rep.ip.ToString(), (int)rep.fGood, rep.lastSuccess, | rep.ip.ToString(), (int)rep.fGood, rep.lastSuccess, | ||||
100.0 * rep.uptime[0], 100.0 * rep.uptime[1], | 100.0 * rep.uptime[0], 100.0 * rep.uptime[1], | ||||
100.0 * rep.uptime[2], 100.0 * rep.uptime[3], | 100.0 * rep.uptime[2], 100.0 * rep.uptime[3], | ||||
100.0 * rep.uptime[4], rep.blocks, rep.services, | 100.0 * rep.uptime[4], rep.blocks, rep.services, | ||||
rep.clientVersion, rep.clientSubVersion); | rep.clientVersion, rep.clientSubVersion); | ||||
stat[0] += rep.uptime[0]; | stat[0] += rep.uptime[0]; | ||||
stat[1] += rep.uptime[1]; | stat[1] += rep.uptime[1]; | ||||
stat[2] += rep.uptime[2]; | stat[2] += rep.uptime[2]; | ||||
stat[3] += rep.uptime[3]; | stat[3] += rep.uptime[3]; | ||||
stat[4] += rep.uptime[4]; | stat[4] += rep.uptime[4]; | ||||
} | } | ||||
fsbridge::ofstream ff{"dnsstats.log", std::ios_base::app}; | fsbridge::ofstream ff{GetDataDir() / "dnsstats.log", | ||||
std::ios_base::app}; | |||||
tfm::format(ff, "%llu %g %g %g %g %g\n", | tfm::format(ff, "%llu %g %g %g %g %g\n", | ||||
(unsigned long long)(time(nullptr)), stat[0], stat[1], | (unsigned long long)(time(nullptr)), stat[0], stat[1], | ||||
stat[2], stat[3], stat[4]); | stat[2], stat[3], stat[4]); | ||||
} | } | ||||
} while (1); | } while (1); | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 104 Lines • ▼ Show 20 Lines | int main(int argc, char **argv) { | ||||
if (fDNS && opts.host.empty()) { | if (fDNS && opts.host.empty()) { | ||||
tfm::format(std::cerr, "No hostname set. Please use -h.\n"); | tfm::format(std::cerr, "No hostname set. Please use -h.\n"); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
if (fDNS && opts.mbox.empty()) { | if (fDNS && opts.mbox.empty()) { | ||||
tfm::format(std::cerr, "No e-mail address set. Please use -m.\n"); | tfm::format(std::cerr, "No e-mail address set. Please use -m.\n"); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
FILE *f = fsbridge::fopen("dnsseed.dat", "r"); | |||||
FILE *f = fsbridge::fopen(GetDataDir() / "dnsseed.dat", "r"); | |||||
if (f) { | if (f) { | ||||
tfm::format(std::cout, "Loading dnsseed.dat..."); | tfm::format(std::cout, "Loading dnsseed.dat..."); | ||||
CAutoFile cf(f, SER_DISK, CLIENT_VERSION); | CAutoFile cf(f, SER_DISK, CLIENT_VERSION); | ||||
cf >> db; | cf >> db; | ||||
if (opts.fWipeBan) { | if (opts.fWipeBan) { | ||||
db.banned.clear(); | db.banned.clear(); | ||||
tfm::format(std::cout, "Ban list wiped..."); | tfm::format(std::cout, "Ban list wiped..."); | ||||
} | } | ||||
Show All 39 Lines |
The diff still mention seederdir.