1 // Copyright (c) 2017 The Zcash developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 #include "deprecation.h"
7 #include "clientversion.h"
9 #include "ui_interface.h"
12 static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION);
14 void EnforceNodeDeprecation(int nHeight, bool forceLogging) {
15 int blocksToDeprecation = DEPRECATION_HEIGHT - nHeight;
16 bool disableDeprecation = (GetArg("-disabledeprecation", "") == CLIENT_VERSION_STR);
17 if (blocksToDeprecation <= 0) {
18 // In order to ensure we only log once per process when deprecation is
19 // disabled (to avoid log spam), we only need to log in two cases:
20 // - The deprecating block just arrived
21 // - This can be triggered more than once if a block chain reorg
22 // occurs, but that's an irregular event that won't cause spam.
23 // - The node is starting
24 if (blocksToDeprecation == 0 || forceLogging) {
25 auto msg = strprintf(_("This version has been deprecated as of block height %d."),
26 DEPRECATION_HEIGHT) + " " +
27 _("You should upgrade to the latest version of Zcash.");
28 if (!disableDeprecation) {
29 msg += " " + strprintf(_("To disable deprecation for this version, set %s%s."),
30 "-disabledeprecation=", CLIENT_VERSION_STR);
32 LogPrintf("*** %s\n", msg);
33 uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR);
35 if (!disableDeprecation) {
38 } else if (blocksToDeprecation == DEPRECATION_WARN_LIMIT ||
39 (blocksToDeprecation < DEPRECATION_WARN_LIMIT && forceLogging)) {
41 if (disableDeprecation) {
42 msg = strprintf(_("This version will be deprecated at block height %d."),
43 DEPRECATION_HEIGHT) + " " +
44 _("You should upgrade to the latest version of Zcash.");
46 msg = strprintf(_("This version will be deprecated at block height %d, and will automatically shut down."),
47 DEPRECATION_HEIGHT) + " " +
48 _("You should upgrade to the latest version of Zcash.") + " " +
49 strprintf(_("To disable deprecation for this version, set %s%s."),
50 "-disabledeprecation=", CLIENT_VERSION_STR);
52 LogPrintf("*** %s\n", msg);
53 uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_WARNING);