@@ -1552,6 +1552,24 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CDiskBlockPos& pos, const uin
1552
1552
return true ;
1553
1553
}
1554
1554
1555
+ /* * Abort with a message */
1556
+ bool AbortNode (const std::string& strMessage, const std::string& userMessage=" " )
1557
+ {
1558
+ strMiscWarning = strMessage;
1559
+ LogPrintf (" *** %s\n " , strMessage);
1560
+ uiInterface.ThreadSafeMessageBox (
1561
+ userMessage.empty () ? _ (" Error: A fatal internal error occured, see debug.log for details" ) : userMessage,
1562
+ " " , CClientUIInterface::MSG_ERROR);
1563
+ StartShutdown ();
1564
+ return false ;
1565
+ }
1566
+
1567
+ bool AbortNode (CValidationState& state, const std::string& strMessage, const std::string& userMessage=" " )
1568
+ {
1569
+ AbortNode (strMessage, userMessage);
1570
+ return state.Error (strMessage);
1571
+ }
1572
+
1555
1573
} // anon namespace
1556
1574
1557
1575
/* *
@@ -1831,7 +1849,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
1831
1849
if (!FindUndoPos (state, pindex->nFile , pos, ::GetSerializeSize (blockundo, SER_DISK, CLIENT_VERSION) + 40 ))
1832
1850
return error (" ConnectBlock(): FindUndoPos failed" );
1833
1851
if (!UndoWriteToDisk (blockundo, pos, pindex->pprev ->GetBlockHash ()))
1834
- return state. Abort ( " Failed to write undo data" );
1852
+ return AbortNode (state, " Failed to write undo data" );
1835
1853
1836
1854
// update nUndoPos in block index
1837
1855
pindex->nUndoPos = pos.nPos ;
@@ -1844,7 +1862,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
1844
1862
1845
1863
if (fTxIndex )
1846
1864
if (!pblocktree->WriteTxIndex (vPos))
1847
- return state. Abort ( " Failed to write transaction index" );
1865
+ return AbortNode (state, " Failed to write transaction index" );
1848
1866
1849
1867
// add this block to the view's block chain
1850
1868
view.SetBestBlock (pindex->GetBlockHash ());
@@ -1938,7 +1956,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
1938
1956
setDirtyBlockIndex.erase (it++);
1939
1957
}
1940
1958
if (!pblocktree->WriteBatchSync (vFiles, nLastBlockFile, vBlocks)) {
1941
- return state. Abort ( " Files to write to block index database" );
1959
+ return AbortNode (state, " Files to write to block index database" );
1942
1960
}
1943
1961
}
1944
1962
// Finally remove any pruned files
@@ -1959,7 +1977,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
1959
1977
return state.Error (" out of disk space" );
1960
1978
// Flush the chainstate (which may refer to block index entries).
1961
1979
if (!pcoinsTip->Flush ())
1962
- return state. Abort ( " Failed to write to coin database" );
1980
+ return AbortNode (state, " Failed to write to coin database" );
1963
1981
nLastFlush = nNow;
1964
1982
}
1965
1983
if ((mode == FLUSH_STATE_ALWAYS || mode == FLUSH_STATE_PERIODIC) && nNow > nLastSetChain + (int64_t )DATABASE_WRITE_INTERVAL * 1000000 ) {
@@ -1968,7 +1986,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
1968
1986
nLastSetChain = nNow;
1969
1987
}
1970
1988
} catch (const std::runtime_error& e) {
1971
- return state. Abort ( std::string (" System error while flushing: " ) + e.what ());
1989
+ return AbortNode (state, std::string (" System error while flushing: " ) + e.what ());
1972
1990
}
1973
1991
return true ;
1974
1992
}
@@ -2032,7 +2050,7 @@ bool static DisconnectTip(CValidationState &state) {
2032
2050
// Read block from disk.
2033
2051
CBlock block;
2034
2052
if (!ReadBlockFromDisk (block, pindexDelete))
2035
- return state. Abort ( " Failed to read block" );
2053
+ return AbortNode (state, " Failed to read block" );
2036
2054
// Apply the block atomically to the chain state.
2037
2055
int64_t nStart = GetTimeMicros ();
2038
2056
{
@@ -2083,7 +2101,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
2083
2101
CBlock block;
2084
2102
if (!pblock) {
2085
2103
if (!ReadBlockFromDisk (block, pindexNew))
2086
- return state. Abort ( " Failed to read block" );
2104
+ return AbortNode (state, " Failed to read block" );
2087
2105
pblock = █
2088
2106
}
2089
2107
// Apply the block atomically to the chain state.
@@ -2790,11 +2808,11 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
2790
2808
return error (" AcceptBlock(): FindBlockPos failed" );
2791
2809
if (dbp == NULL )
2792
2810
if (!WriteBlockToDisk (block, blockPos))
2793
- return state. Abort ( " Failed to write block" );
2811
+ AbortNode (state, " Failed to write block" );
2794
2812
if (!ReceivedBlockTransactions (block, state, pindex, blockPos))
2795
2813
return error (" AcceptBlock(): ReceivedBlockTransactions failed" );
2796
2814
} catch (const std::runtime_error& e) {
2797
- return state. Abort ( std::string (" System error: " ) + e.what ());
2815
+ return AbortNode (state, std::string (" System error: " ) + e.what ());
2798
2816
}
2799
2817
2800
2818
if (fCheckForPruning )
@@ -2869,24 +2887,6 @@ bool TestBlockValidity(CValidationState &state, const CBlock& block, CBlockIndex
2869
2887
return true ;
2870
2888
}
2871
2889
2872
-
2873
-
2874
-
2875
-
2876
-
2877
-
2878
-
2879
- bool AbortNode (const std::string &strMessage, const std::string &userMessage) {
2880
- strMiscWarning = strMessage;
2881
- LogPrintf (" *** %s\n " , strMessage);
2882
- uiInterface.ThreadSafeMessageBox (
2883
- userMessage.empty () ? _ (" Error: A fatal internal error occured, see debug.log for details" ) : userMessage,
2884
- " " , CClientUIInterface::MSG_ERROR);
2885
- StartShutdown ();
2886
- return false ;
2887
- }
2888
-
2889
-
2890
2890
/* *
2891
2891
* BLOCK PRUNING CODE
2892
2892
*/
0 commit comments