@@ -2206,14 +2206,18 @@ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &
2206
2206
void FlushStateToDisk () {
2207
2207
CValidationState state;
2208
2208
const CChainParams& chainparams = Params ();
2209
- FlushStateToDisk (chainparams, state, FlushStateMode::ALWAYS);
2209
+ if (!FlushStateToDisk (chainparams, state, FlushStateMode::ALWAYS)) {
2210
+ LogPrintf (" %s: failed to flush state (%s)\n " , __func__, FormatStateMessage (state));
2211
+ }
2210
2212
}
2211
2213
2212
2214
void PruneAndFlush () {
2213
2215
CValidationState state;
2214
2216
fCheckForPruning = true ;
2215
2217
const CChainParams& chainparams = Params ();
2216
- FlushStateToDisk (chainparams, state, FlushStateMode::NONE);
2218
+ if (!FlushStateToDisk (chainparams, state, FlushStateMode::NONE)) {
2219
+ LogPrintf (" %s: failed to flush state (%s)\n " , __func__, FormatStateMessage (state));
2220
+ }
2217
2221
}
2218
2222
2219
2223
static void DoWarning (const std::string& strWarning)
@@ -3520,15 +3524,15 @@ bool ProcessNewBlock(const CChainParams& chainparams, const std::shared_ptr<cons
3520
3524
}
3521
3525
if (!ret) {
3522
3526
GetMainSignals ().BlockChecked (*pblock, state);
3523
- return error (" %s: AcceptBlock FAILED (%s)" , __func__, state. GetDebugMessage ( ));
3527
+ return error (" %s: AcceptBlock FAILED (%s)" , __func__, FormatStateMessage (state ));
3524
3528
}
3525
3529
}
3526
3530
3527
3531
NotifyHeaderTip ();
3528
3532
3529
3533
CValidationState state; // Only used to report errors, not invalidity - ignore it
3530
3534
if (!g_chainstate.ActivateBestChain (state, chainparams, pblock))
3531
- return error (" %s: ActivateBestChain failed" , __func__);
3535
+ return error (" %s: ActivateBestChain failed (%s) " , __func__, FormatStateMessage (state) );
3532
3536
3533
3537
return true ;
3534
3538
}
@@ -3646,7 +3650,9 @@ void PruneBlockFilesManual(int nManualPruneHeight)
3646
3650
{
3647
3651
CValidationState state;
3648
3652
const CChainParams& chainparams = Params ();
3649
- FlushStateToDisk (chainparams, state, FlushStateMode::NONE, nManualPruneHeight);
3653
+ if (!FlushStateToDisk (chainparams, state, FlushStateMode::NONE, nManualPruneHeight)) {
3654
+ LogPrintf (" %s: failed to flush state (%s)\n " , __func__, FormatStateMessage (state));
3655
+ }
3650
3656
}
3651
3657
3652
3658
/* *
@@ -3900,6 +3906,7 @@ bool LoadChainTip(const CChainParams& chainparams)
3900
3906
LogPrintf (" %s: Connecting genesis block...\n " , __func__);
3901
3907
CValidationState state;
3902
3908
if (!ActivateBestChain (state, chainparams)) {
3909
+ LogPrintf (" %s: failed to activate chain (%s)\n " , __func__, FormatStateMessage (state));
3903
3910
return false ;
3904
3911
}
3905
3912
}
@@ -4014,7 +4021,7 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
4014
4021
if (!ReadBlockFromDisk (block, pindex, chainparams.GetConsensus ()))
4015
4022
return error (" VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s" , pindex->nHeight , pindex->GetBlockHash ().ToString ());
4016
4023
if (!g_chainstate.ConnectBlock (block, state, pindex, coins, chainparams))
4017
- return error (" VerifyDB(): *** found unconnectable block at %d, hash=%s" , pindex->nHeight , pindex->GetBlockHash ().ToString ());
4024
+ return error (" VerifyDB(): *** found unconnectable block at %d, hash=%s (%s) " , pindex->nHeight , pindex->GetBlockHash ().ToString (), FormatStateMessage (state ));
4018
4025
}
4019
4026
}
4020
4027
@@ -4144,11 +4151,13 @@ bool CChainState::RewindBlockIndex(const CChainParams& params)
4144
4151
break ;
4145
4152
}
4146
4153
if (!DisconnectTip (state, params, nullptr )) {
4147
- return error (" RewindBlockIndex: unable to disconnect block at height %i" , pindex->nHeight );
4154
+ return error (" RewindBlockIndex: unable to disconnect block at height %i (%s) " , pindex->nHeight , FormatStateMessage (state) );
4148
4155
}
4149
4156
// Occasionally flush state to disk.
4150
- if (!FlushStateToDisk (params, state, FlushStateMode::PERIODIC))
4157
+ if (!FlushStateToDisk (params, state, FlushStateMode::PERIODIC)) {
4158
+ LogPrintf (" RewindBlockIndex: unable to flush state to disk (%s)\n " , FormatStateMessage (state));
4151
4159
return false ;
4160
+ }
4152
4161
}
4153
4162
4154
4163
// Reduce validity flag and have-data flags.
@@ -4214,6 +4223,7 @@ bool RewindBlockIndex(const CChainParams& params) {
4214
4223
// it'll get called a bunch real soon.
4215
4224
CValidationState state;
4216
4225
if (!FlushStateToDisk (params, state, FlushStateMode::ALWAYS)) {
4226
+ LogPrintf (" RewindBlockIndex: unable to flush state to disk (%s)\n " , FormatStateMessage (state));
4217
4227
return false ;
4218
4228
}
4219
4229
}
@@ -4300,7 +4310,7 @@ bool CChainState::LoadGenesisBlock(const CChainParams& chainparams)
4300
4310
CBlockIndex *pindex = AddToBlockIndex (block);
4301
4311
CValidationState state;
4302
4312
if (!ReceivedBlockTransactions (block, state, pindex, blockPos, chainparams.GetConsensus ()))
4303
- return error (" %s: genesis block not accepted" , __func__);
4313
+ return error (" %s: genesis block not accepted (%s) " , __func__, FormatStateMessage (state) );
4304
4314
} catch (const std::runtime_error& e) {
4305
4315
return error (" %s: failed to write genesis block: %s" , __func__, e.what ());
4306
4316
}
0 commit comments