Make AbortNode() aware of MSG_NOPREFIX flag

This commit is contained in:
Hennadii Stepanov 2019-04-30 20:16:45 +03:00
parent 96fd4ee02f
commit f724f31401
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -1374,20 +1374,22 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
} }
/** Abort with a message */ /** Abort with a message */
static bool AbortNode(const std::string& strMessage, const std::string& userMessage="") static bool AbortNode(const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
{ {
SetMiscWarning(strMessage); SetMiscWarning(strMessage);
LogPrintf("*** %s\n", strMessage); LogPrintf("*** %s\n", strMessage);
uiInterface.ThreadSafeMessageBox( if (!userMessage.empty()) {
userMessage.empty() ? _("Error: A fatal internal error occurred, see debug.log for details") : userMessage, uiInterface.ThreadSafeMessageBox(userMessage, "", CClientUIInterface::MSG_ERROR | prefix);
"", CClientUIInterface::MSG_ERROR); } else {
uiInterface.ThreadSafeMessageBox(_("Error: A fatal internal error occurred, see debug.log for details"), "", CClientUIInterface::MSG_ERROR | CClientUIInterface::MSG_NOPREFIX);
}
StartShutdown(); StartShutdown();
return false; return false;
} }
static bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage="") static bool AbortNode(CValidationState& state, const std::string& strMessage, const std::string& userMessage = "", unsigned int prefix = 0)
{ {
AbortNode(strMessage, userMessage); AbortNode(strMessage, userMessage, prefix);
return state.Error(strMessage); return state.Error(strMessage);
} }
@ -1998,7 +2000,7 @@ bool CChainState::FlushStateToDisk(
if (fDoFullFlush || fPeriodicWrite) { if (fDoFullFlush || fPeriodicWrite) {
// Depend on nMinDiskSpace to ensure we can write block index // Depend on nMinDiskSpace to ensure we can write block index
if (!CheckDiskSpace(GetBlocksDir())) { if (!CheckDiskSpace(GetBlocksDir())) {
return AbortNode(state, "Disk space is low!", _("Error: Disk space is low!")); return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!"), CClientUIInterface::MSG_NOPREFIX);
} }
// First make sure all block and undo data is flushed to disk. // First make sure all block and undo data is flushed to disk.
FlushBlockFile(); FlushBlockFile();
@ -2033,7 +2035,7 @@ bool CChainState::FlushStateToDisk(
// an overestimation, as most will delete an existing entry or // an overestimation, as most will delete an existing entry or
// overwrite one. Still, use a conservative safety factor of 2. // overwrite one. Still, use a conservative safety factor of 2.
if (!CheckDiskSpace(GetDataDir(), 48 * 2 * 2 * pcoinsTip->GetCacheSize())) { if (!CheckDiskSpace(GetDataDir(), 48 * 2 * 2 * pcoinsTip->GetCacheSize())) {
return AbortNode(state, "Disk space is low!", _("Error: Disk space is low!")); return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!"), CClientUIInterface::MSG_NOPREFIX);
} }
// Flush the chainstate (which may refer to block index entries). // Flush the chainstate (which may refer to block index entries).
if (!pcoinsTip->Flush()) if (!pcoinsTip->Flush())
@ -2899,7 +2901,7 @@ static bool FindBlockPos(FlatFilePos &pos, unsigned int nAddSize, unsigned int n
bool out_of_space; bool out_of_space;
size_t bytes_allocated = BlockFileSeq().Allocate(pos, nAddSize, out_of_space); size_t bytes_allocated = BlockFileSeq().Allocate(pos, nAddSize, out_of_space);
if (out_of_space) { if (out_of_space) {
return AbortNode("Disk space is low!", _("Error: Disk space is low!")); return AbortNode("Disk space is too low!", _("Error: Disk space is too low!"), CClientUIInterface::MSG_NOPREFIX);
} }
if (bytes_allocated != 0 && fPruneMode) { if (bytes_allocated != 0 && fPruneMode) {
fCheckForPruning = true; fCheckForPruning = true;
@ -2923,7 +2925,7 @@ static bool FindUndoPos(CValidationState &state, int nFile, FlatFilePos &pos, un
bool out_of_space; bool out_of_space;
size_t bytes_allocated = UndoFileSeq().Allocate(pos, nAddSize, out_of_space); size_t bytes_allocated = UndoFileSeq().Allocate(pos, nAddSize, out_of_space);
if (out_of_space) { if (out_of_space) {
return AbortNode(state, "Disk space is low!", _("Error: Disk space is low!")); return AbortNode(state, "Disk space is too low!", _("Error: Disk space is too low!"), CClientUIInterface::MSG_NOPREFIX);
} }
if (bytes_allocated != 0 && fPruneMode) { if (bytes_allocated != 0 && fPruneMode) {
fCheckForPruning = true; fCheckForPruning = true;