]>
Commit | Line | Data |
---|---|---|
5b3bc971 JG |
1 | // Copyright (c) 2017 The Zcash developers |
2 | // Distributed under the MIT software license, see the accompanying | |
bc909a7a | 3 | // file COPYING or https://www.opensource.org/licenses/mit-license.php . |
5b3bc971 JG |
4 | |
5 | #include "deprecation.h" | |
6 | ||
7b4d0c77 | 7 | #include "alert.h" |
5b3bc971 JG |
8 | #include "clientversion.h" |
9 | #include "init.h" | |
10 | #include "ui_interface.h" | |
11 | #include "util.h" | |
e882e3c0 | 12 | #include "chainparams.h" |
5b3bc971 JG |
13 | |
14 | static const std::string CLIENT_VERSION_STR = FormatVersion(CLIENT_VERSION); | |
9edf27ec | 15 | extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; |
5b3bc971 | 16 | |
7b4d0c77 | 17 | void EnforceNodeDeprecation(int nHeight, bool forceLogging, bool fThread) { |
e882e3c0 BM |
18 | |
19 | // Do not enforce deprecation in regtest or on testnet | |
20 | std::string networkID = Params().NetworkIDString(); | |
9feb4b9e | 21 | std::string msg; |
22 | ||
e871bb78 | 23 | if (networkID != "main" || strcmp(ASSETCHAINS_SYMBOL, "VRSC") != 0 ) return; |
e882e3c0 | 24 | |
5b3bc971 | 25 | int blocksToDeprecation = DEPRECATION_HEIGHT - nHeight; |
5b3bc971 JG |
26 | if (blocksToDeprecation <= 0) { |
27 | // In order to ensure we only log once per process when deprecation is | |
28 | // disabled (to avoid log spam), we only need to log in two cases: | |
29 | // - The deprecating block just arrived | |
30 | // - This can be triggered more than once if a block chain reorg | |
31 | // occurs, but that's an irregular event that won't cause spam. | |
32 | // - The node is starting | |
33 | if (blocksToDeprecation == 0 || forceLogging) { | |
9feb4b9e | 34 | msg = strprintf(_("This version has been deprecated as of block height %d."), |
5b3bc971 | 35 | DEPRECATION_HEIGHT) + " " + |
c754dbcf | 36 | _("You should upgrade to the latest version of Verus."); |
5b3bc971 | 37 | LogPrintf("*** %s\n", msg); |
7b4d0c77 | 38 | CAlert::Notify(msg, fThread); |
5b3bc971 JG |
39 | uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); |
40 | } | |
c74ab335 | 41 | StartShutdown(); |
9feb4b9e | 42 | } else if (blocksToDeprecation == DEPRECATION_WARN_LIMIT || (blocksToDeprecation < DEPRECATION_WARN_LIMIT && forceLogging)) { |
43 | msg = strprintf(_("This version will be deprecated at block height %d, and will automatically shut down."), | |
5b3bc971 | 44 | DEPRECATION_HEIGHT) + " " + |
c754dbcf | 45 | _("You should upgrade to the latest version of Verus."); |
d82a969a | 46 | LogPrintf("*** %s\n", msg); |
47 | CAlert::Notify(msg, fThread); | |
48 | uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_WARNING); | |
5b3bc971 | 49 | } |
e70b1af2 | 50 | } |