diff --git a/doc/release-notes.md b/doc/release-notes.md --- a/doc/release-notes.md +++ b/doc/release-notes.md @@ -22,3 +22,9 @@ - The `importmulti` RPC will now contain a new per-request `warnings` field with strings that explain when fields are being ignored or inconsistent, if any. + +Seeder +------ +- Added the `datadir` option to the seeder allowing a directory to be + specified for the files the seeder writes to and reads from (default is the + `~/.bitcoin/seeder` directory). See help for more details. diff --git a/src/seeder/main.cpp b/src/seeder/main.cpp --- a/src/seeder/main.cpp +++ b/src/seeder/main.cpp @@ -96,6 +96,32 @@ ipv6_proxy = gArgs.GetArg("-proxyipv6", DEFAULT_IPV6_PROXY); SelectParams(gArgs.GetChainName()); + if (!gArgs.IsArgSet("-datadir")) { + fs::path path = GetDefaultDataDir() / "seeder"; + 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")) { // Parse whitelist additions std::string flagString = gArgs.GetArg("-filter", ""); @@ -156,6 +182,13 @@ gArgs.AddArg("-help-debug", "Show all debugging options (usage: --help -help-debug)", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); + gArgs.AddArg( + "-datadir=