Enable high-priority alerts to put the RPC into safe mode

This reverts the changes in 986b5e257e and adds a
priority check.

Closes #1106
This commit is contained in:
Jack Grigg 2016-09-04 18:25:33 +12:00
parent 976479f824
commit a40034f7d6
5 changed files with 13 additions and 4 deletions

View File

@ -41,7 +41,7 @@ void CUnsignedAlert::SetNull()
strComment.clear(); strComment.clear();
strStatusBar.clear(); strStatusBar.clear();
strReserved.clear(); strRPCError.clear();
} }
std::string CUnsignedAlert::ToString() const std::string CUnsignedAlert::ToString() const
@ -66,6 +66,7 @@ std::string CUnsignedAlert::ToString() const
" nPriority = %d\n" " nPriority = %d\n"
" strComment = \"%s\"\n" " strComment = \"%s\"\n"
" strStatusBar = \"%s\"\n" " strStatusBar = \"%s\"\n"
" strRPCError = \"%s\"\n"
")\n", ")\n",
nVersion, nVersion,
nRelayUntil, nRelayUntil,
@ -78,7 +79,8 @@ std::string CUnsignedAlert::ToString() const
strSetSubVer, strSetSubVer,
nPriority, nPriority,
strComment, strComment,
strStatusBar); strStatusBar,
strRPCError);
} }
void CAlert::SetNull() void CAlert::SetNull()

View File

@ -44,7 +44,7 @@ public:
// Actions // Actions
std::string strComment; std::string strComment;
std::string strStatusBar; std::string strStatusBar;
std::string strReserved; std::string strRPCError;
ADD_SERIALIZE_METHODS; ADD_SERIALIZE_METHODS;
@ -64,7 +64,7 @@ public:
READWRITE(LIMITED_STRING(strComment, 65536)); READWRITE(LIMITED_STRING(strComment, 65536));
READWRITE(LIMITED_STRING(strStatusBar, 256)); READWRITE(LIMITED_STRING(strStatusBar, 256));
READWRITE(LIMITED_STRING(strReserved, 256)); READWRITE(LIMITED_STRING(strRPCError, 256));
} }
void SetNull(); void SetNull();

View File

@ -4069,6 +4069,9 @@ string GetWarnings(string strFor)
{ {
nPriority = alert.nPriority; nPriority = alert.nPriority;
strStatusBar = alert.strStatusBar; strStatusBar = alert.strStatusBar;
if (alert.nPriority >= ALERT_PRIORITY_SAFE_MODE) {
strRPC = alert.strRPCError;
}
} }
} }
} }

View File

@ -57,6 +57,8 @@ static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000; static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000;
/** Default for accepting alerts from the P2P network. */ /** Default for accepting alerts from the P2P network. */
static const bool DEFAULT_ALERTS = true; static const bool DEFAULT_ALERTS = true;
/** Minimum alert priority for enabling safe mode. */
static const int ALERT_PRIORITY_SAFE_MODE = 4000;
/** The maximum size for transactions we're willing to relay/mine */ /** The maximum size for transactions we're willing to relay/mine */
static const unsigned int MAX_STANDARD_TX_SIZE = 100000; static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
/** Maximum number of signature check operations in an IsStandard() P2SH script */ /** Maximum number of signature check operations in an IsStandard() P2SH script */

View File

@ -85,9 +85,11 @@ void ThreadSendAlert()
// 1000 for Misc warnings like out of disk space and clock is wrong // 1000 for Misc warnings like out of disk space and clock is wrong
// 2000 for longer invalid proof-of-work chain // 2000 for longer invalid proof-of-work chain
// Higher numbers mean higher priority // Higher numbers mean higher priority
// 4000 or higher will put the RPC into safe mode
alert.nPriority = 5000; alert.nPriority = 5000;
alert.strComment = ""; alert.strComment = "";
alert.strStatusBar = "URGENT: Upgrade required: see https://z.cash"; alert.strStatusBar = "URGENT: Upgrade required: see https://z.cash";
alert.strRPCError = "URGENT: Upgrade required: see https://z.cash";
// Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done: // Set specific client version/versions here. If setSubVer is empty, no filtering on subver is done:
// alert.setSubVer.insert(std::string("/Satoshi:0.7.2/")); // alert.setSubVer.insert(std::string("/Satoshi:0.7.2/"));