@@ -2181,14 +2181,18 @@ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &
2181
2181
void FlushStateToDisk () {
2182
2182
CValidationState state;
2183
2183
const CChainParams& chainparams = Params ();
2184
- FlushStateToDisk (chainparams, state, FlushStateMode::ALWAYS);
2184
+ if (!FlushStateToDisk (chainparams, state, FlushStateMode::ALWAYS)) {
2185
+ LogPrintf (" %s: failed to flush state (%s)\n " , __func__, FormatStateMessage (state));
2186
+ }
2185
2187
}
2186
2188
2187
2189
void PruneAndFlush () {
2188
2190
CValidationState state;
2189
2191
fCheckForPruning = true ;
2190
2192
const CChainParams& chainparams = Params ();
2191
- FlushStateToDisk (chainparams, state, FlushStateMode::NONE);
2193
+ if (!FlushStateToDisk (chainparams, state, FlushStateMode::NONE)) {
2194
+ LogPrintf (" %s: failed to flush state (%s)\n " , __func__, FormatStateMessage (state));
2195
+ }
2192
2196
}
2193
2197
2194
2198
static void DoWarning (const std::string& strWarning)
@@ -3489,15 +3493,15 @@ bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<cons
3489
3493
}
3490
3494
if (!ret) {
3491
3495
GetMainSignals ().BlockChecked (*pblock, state);
3492
- return error (" %s: AcceptBlock FAILED (%s)" , __func__, state. GetDebugMessage ( ));
3496
+ return error (" %s: AcceptBlock FAILED (%s)" , __func__, FormatStateMessage (state ));
3493
3497
}
3494
3498
}
3495
3499
3496
3500
NotifyHeaderTip ();
3497
3501
3498
3502
CValidationState state; // Only used to report errors, not invalidity - ignore it
3499
3503
if (!g_chainstate.ActivateBestChain (state, chainparams, pblock))
3500
- return error (" %s: ActivateBestChain failed" , __func__);
3504
+ return error (" %s: ActivateBestChain failed (%s) " , __func__, FormatStateMessage (state) );
3501
3505
3502
3506
return true ;
3503
3507
}
@@ -3615,7 +3619,9 @@ void PruneBlockFilesManual(int nManualPruneHeight)
3615
3619
{
3616
3620
CValidationState state;
3617
3621
const CChainParams& chainparams = Params ();
3618
- FlushStateToDisk (chainparams, state, FlushStateMode::NONE, nManualPruneHeight);
3622
+ if (!FlushStateToDisk (chainparams, state, FlushStateMode::NONE, nManualPruneHeight)) {
3623
+ LogPrintf (" %s: failed to flush state (%s)\n " , __func__, FormatStateMessage (state));
3624
+ }
3619
3625
}
3620
3626
3621
3627
/* *
@@ -3869,6 +3875,7 @@ bool LoadChainTip(const CChainParams& chainparams)
3869
3875
LogPrintf (" %s: Connecting genesis block...\n " , __func__);
3870
3876
CValidationState state;
3871
3877
if (!ActivateBestChain (state, chainparams)) {
3878
+ LogPrintf (" %s: failed to activate chain (%s)\n " , __func__, FormatStateMessage (state));
3872
3879
return false ;
3873
3880
}
3874
3881
}
@@ -3983,7 +3990,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
3983
3990
if (!ReadBlockFromDisk (block, pindex, chainparams.GetConsensus ()))
3984
3991
return error (" VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s" , pindex->nHeight , pindex->GetBlockHash ().ToString ());
3985
3992
if (!g_chainstate.ConnectBlock (block, state, pindex, coins, chainparams))
3986
- return error (" VerifyDB(): *** found unconnectable block at %d, hash=%s" , pindex->nHeight , pindex->GetBlockHash ().ToString ());
3993
+ return error (" VerifyDB(): *** found unconnectable block at %d, hash=%s (%s) " , pindex->nHeight , pindex->GetBlockHash ().ToString (), FormatStateMessage (state ));
3987
3994
}
3988
3995
}
3989
3996
@@ -4110,11 +4117,13 @@ bool CChainState::RewindBlockIndex(const CChainParams& params)
4110
4117
break ;
4111
4118
}
4112
4119
if (!DisconnectTip (state, params, nullptr )) {
4113
- return error (" RewindBlockIndex: unable to disconnect block at height %i" , pindex->nHeight );
4120
+ return error (" RewindBlockIndex: unable to disconnect block at height %i (%s) " , pindex->nHeight , FormatStateMessage (state) );
4114
4121
}
4115
4122
// Occasionally flush state to disk.
4116
- if (!FlushStateToDisk (params, state, FlushStateMode::PERIODIC))
4123
+ if (!FlushStateToDisk (params, state, FlushStateMode::PERIODIC)) {
4124
+ LogPrintf (" RewindBlockIndex: unable to flush state to disk (%s)\n " , FormatStateMessage (state));
4117
4125
return false ;
4126
+ }
4118
4127
}
4119
4128
4120
4129
// Reduce validity flag and have-data flags.
@@ -4180,6 +4189,7 @@ bool RewindBlockIndex(const CChainParams& params) {
4180
4189
// it'll get called a bunch real soon.
4181
4190
CValidationState state;
4182
4191
if (!FlushStateToDisk (params, state, FlushStateMode::ALWAYS)) {
4192
+ LogPrintf (" RewindBlockIndex: unable to flush state to disk (%s)\n " , FormatStateMessage (state));
4183
4193
return false ;
4184
4194
}
4185
4195
}
@@ -4266,7 +4276,7 @@ bool CChainState::LoadGenesisBlock(const CChainParams& chainparams)
4266
4276
CBlockIndex *pindex = AddToBlockIndex (block);
4267
4277
CValidationState state;
4268
4278
if (!ReceivedBlockTransactions (block, state, pindex, blockPos, chainparams.GetConsensus ()))
4269
- return error (" %s: genesis block not accepted" , __func__);
4279
+ return error (" %s: genesis block not accepted (%s) " , __func__, FormatStateMessage (state) );
4270
4280
} catch (const std::runtime_error& e) {
4271
4281
return error (" %s: failed to write genesis block: %s" , __func__, e.what ());
4272
4282
}
0 commit comments