| 922 | } |
| 923 | |
| 924 | bool AppInitParameterInteraction() |
| 925 | { |
| 926 | const CChainParams& chainparams = Params(); |
| 927 | // ********************************************************* Step 2: parameter interactions |
| 928 | |
| 929 | // also see: InitParameterInteraction() |
| 930 | |
| 931 | if (!fs::is_directory(GetBlocksDir(false))) { |
| 932 | return InitError(strprintf(_("Specified blocks directory \"%s\" does not exist."), gArgs.GetArg("-blocksdir", "").c_str())); |
| 933 | } |
| 934 | |
| 935 | // if using block pruning, then disallow txindex |
| 936 | if (gArgs.GetArg("-prune", 0)) { |
| 937 | if (gArgs.GetBoolArg("-txindex", DEFAULT_TXINDEX)) |
| 938 | return InitError(_("Prune mode is incompatible with -txindex.")); |
| 939 | } |
| 940 | |
| 941 | // -bind and -whitebind can't be set when not listening |
| 942 | size_t nUserBind = gArgs.GetArgs("-bind").size() + gArgs.GetArgs("-whitebind").size(); |
| 943 | if (nUserBind != 0 && !gArgs.GetBoolArg("-listen", DEFAULT_LISTEN)) { |
| 944 | return InitError("Cannot set -bind or -whitebind together with -listen=0"); |
| 945 | } |
| 946 | |
| 947 | // Make sure enough file descriptors are available |
| 948 | int nBind = std::max(nUserBind, size_t(1)); |
| 949 | nUserMaxConnections = gArgs.GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); |
| 950 | nMaxConnections = std::max(nUserMaxConnections, 0); |
| 951 | |
| 952 | // Trim requested connection counts, to fit into system limitations |
| 953 | // <int> in std::min<int>(...) to work around FreeBSD compilation issue described in #2695 |
| 954 | nMaxConnections = std::max(std::min<int>(nMaxConnections, FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS), 0); |
| 955 | nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS + MAX_ADDNODE_CONNECTIONS); |
| 956 | if (nFD < MIN_CORE_FILEDESCRIPTORS) |
| 957 | return InitError(_("Not enough file descriptors available.")); |
| 958 | nMaxConnections = std::min(nFD - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS, nMaxConnections); |
| 959 | |
| 960 | if (nMaxConnections < nUserMaxConnections) |
| 961 | InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections)); |
| 962 | |
| 963 | // ********************************************************* Step 3: parameter-to-internal-flags |
| 964 | if (gArgs.IsArgSet("-debug")) { |
| 965 | // Special-case: if -debug=0/-nodebug is set, turn off debugging messages |
| 966 | const std::vector<std::string> categories = gArgs.GetArgs("-debug"); |
| 967 | |
| 968 | if (std::none_of(categories.begin(), categories.end(), |
| 969 | [](std::string cat){return cat == "0" || cat == "none";})) { |
| 970 | for (const auto& cat : categories) { |
| 971 | if (!g_logger->EnableCategory(cat)) { |
| 972 | InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debug", cat)); |
| 973 | } |
| 974 | } |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | // Now remove the logging categories which were explicitly excluded |
| 979 | for (const std::string& cat : gArgs.GetArgs("-debugexclude")) { |
| 980 | if (!g_logger->DisableCategory(cat)) { |
| 981 | InitWarning(strprintf(_("Unsupported logging category %s=%s."), "-debugexclude", cat)); |
no test coverage detected