@ -1688,7 +1688,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
if ( ! FindUndoPos ( state , pindex - > nFile , pos , : : GetSerializeSize ( blockundo , SER_DISK , CLIENT_VERSION ) + 40 ) )
if ( ! FindUndoPos ( state , pindex - > nFile , pos , : : GetSerializeSize ( blockundo , SER_DISK , CLIENT_VERSION ) + 40 ) )
return error ( " ConnectBlock() : FindUndoPos failed " ) ;
return error ( " ConnectBlock() : FindUndoPos failed " ) ;
if ( ! blockundo . WriteToDisk ( pos , pindex - > pprev - > GetBlockHash ( ) ) )
if ( ! blockundo . WriteToDisk ( pos , pindex - > pprev - > GetBlockHash ( ) ) )
return state . Abort ( _ ( " Failed to write undo data " ) ) ;
return state . Abort ( " Failed to write undo data " ) ;
// update nUndoPos in block index
// update nUndoPos in block index
pindex - > nUndoPos = pos . nPos ;
pindex - > nUndoPos = pos . nPos ;
@ -1699,12 +1699,12 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
CDiskBlockIndex blockindex ( pindex ) ;
CDiskBlockIndex blockindex ( pindex ) ;
if ( ! pblocktree - > WriteBlockIndex ( blockindex ) )
if ( ! pblocktree - > WriteBlockIndex ( blockindex ) )
return state . Abort ( _ ( " Failed to write block index " ) ) ;
return state . Abort ( " Failed to write block index " ) ;
}
}
if ( fTxIndex )
if ( fTxIndex )
if ( ! pblocktree - > WriteTxIndex ( vPos ) )
if ( ! pblocktree - > WriteTxIndex ( vPos ) )
return state . Abort ( _ ( " Failed to write transaction index " ) ) ;
return state . Abort ( " Failed to write transaction index " ) ;
// add this block to the view's block chain
// add this block to the view's block chain
bool ret ;
bool ret ;
@ -1739,7 +1739,7 @@ bool static WriteChainState(CValidationState &state) {
FlushBlockFile ( ) ;
FlushBlockFile ( ) ;
pblocktree - > Sync ( ) ;
pblocktree - > Sync ( ) ;
if ( ! pcoinsTip - > Flush ( ) )
if ( ! pcoinsTip - > Flush ( ) )
return state . Abort ( _ ( " Failed to write to coin database " ) ) ;
return state . Abort ( " Failed to write to coin database " ) ;
nLastWrite = GetTimeMicros ( ) ;
nLastWrite = GetTimeMicros ( ) ;
}
}
return true ;
return true ;
@ -1787,7 +1787,7 @@ bool static DisconnectTip(CValidationState &state) {
// Read block from disk.
// Read block from disk.
CBlock block ;
CBlock block ;
if ( ! ReadBlockFromDisk ( block , pindexDelete ) )
if ( ! ReadBlockFromDisk ( block , pindexDelete ) )
return state . Abort ( _ ( " Failed to read block " ) ) ;
return state . Abort ( " Failed to read block " ) ;
// Apply the block atomically to the chain state.
// Apply the block atomically to the chain state.
int64_t nStart = GetTimeMicros ( ) ;
int64_t nStart = GetTimeMicros ( ) ;
{
{
@ -1836,7 +1836,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
CBlock block ;
CBlock block ;
if ( ! pblock ) {
if ( ! pblock ) {
if ( ! ReadBlockFromDisk ( block , pindexNew ) )
if ( ! ReadBlockFromDisk ( block , pindexNew ) )
return state . Abort ( _ ( " Failed to read block " ) ) ;
return state . Abort ( " Failed to read block " ) ;
pblock = & block ;
pblock = & block ;
}
}
// Apply the block atomically to the chain state.
// Apply the block atomically to the chain state.
@ -1990,7 +1990,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
CheckForkWarningConditions ( ) ;
CheckForkWarningConditions ( ) ;
if ( ! pblocktree - > Flush ( ) )
if ( ! pblocktree - > Flush ( ) )
return state . Abort ( _ ( " Failed to sync block index " ) ) ;
return state . Abort ( " Failed to sync block index " ) ;
return true ;
return true ;
}
}
@ -2097,7 +2097,7 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl
setBlockIndexValid . insert ( pindexNew ) ;
setBlockIndexValid . insert ( pindexNew ) ;
if ( ! pblocktree - > WriteBlockIndex ( CDiskBlockIndex ( pindexNew ) ) )
if ( ! pblocktree - > WriteBlockIndex ( CDiskBlockIndex ( pindexNew ) ) )
return state . Abort ( _ ( " Failed to write block index " ) ) ;
return state . Abort ( " Failed to write block index " ) ;
return true ;
return true ;
}
}
@ -2149,7 +2149,7 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd
}
}
if ( ! pblocktree - > WriteBlockFileInfo ( nLastBlockFile , infoLastBlockFile ) )
if ( ! pblocktree - > WriteBlockFileInfo ( nLastBlockFile , infoLastBlockFile ) )
return state . Abort ( _ ( " Failed to write file info " ) ) ;
return state . Abort ( " Failed to write file info " ) ;
if ( fUpdatedLast )
if ( fUpdatedLast )
pblocktree - > WriteLastBlockFile ( nLastBlockFile ) ;
pblocktree - > WriteLastBlockFile ( nLastBlockFile ) ;
@ -2167,15 +2167,15 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
pos . nPos = infoLastBlockFile . nUndoSize ;
pos . nPos = infoLastBlockFile . nUndoSize ;
nNewSize = ( infoLastBlockFile . nUndoSize + = nAddSize ) ;
nNewSize = ( infoLastBlockFile . nUndoSize + = nAddSize ) ;
if ( ! pblocktree - > WriteBlockFileInfo ( nLastBlockFile , infoLastBlockFile ) )
if ( ! pblocktree - > WriteBlockFileInfo ( nLastBlockFile , infoLastBlockFile ) )
return state . Abort ( _ ( " Failed to write block info " ) ) ;
return state . Abort ( " Failed to write block info " ) ;
} else {
} else {
CBlockFileInfo info ;
CBlockFileInfo info ;
if ( ! pblocktree - > ReadBlockFileInfo ( nFile , info ) )
if ( ! pblocktree - > ReadBlockFileInfo ( nFile , info ) )
return state . Abort ( _ ( " Failed to read block info " ) ) ;
return state . Abort ( " Failed to read block info " ) ;
pos . nPos = info . nUndoSize ;
pos . nPos = info . nUndoSize ;
nNewSize = ( info . nUndoSize + = nAddSize ) ;
nNewSize = ( info . nUndoSize + = nAddSize ) ;
if ( ! pblocktree - > WriteBlockFileInfo ( nFile , info ) )
if ( ! pblocktree - > WriteBlockFileInfo ( nFile , info ) )
return state . Abort ( _ ( " Failed to write block info " ) ) ;
return state . Abort ( " Failed to write block info " ) ;
}
}
unsigned int nOldChunks = ( pos . nPos + UNDOFILE_CHUNK_SIZE - 1 ) / UNDOFILE_CHUNK_SIZE ;
unsigned int nOldChunks = ( pos . nPos + UNDOFILE_CHUNK_SIZE - 1 ) / UNDOFILE_CHUNK_SIZE ;
@ -2392,11 +2392,11 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
return error ( " AcceptBlock() : FindBlockPos failed " ) ;
return error ( " AcceptBlock() : FindBlockPos failed " ) ;
if ( dbp = = NULL )
if ( dbp = = NULL )
if ( ! WriteBlockToDisk ( block , blockPos ) )
if ( ! WriteBlockToDisk ( block , blockPos ) )
return state . Abort ( _ ( " Failed to write block " ) ) ;
return state . Abort ( " Failed to write block " ) ;
if ( ! ReceivedBlockTransactions ( block , state , pindex , blockPos ) )
if ( ! ReceivedBlockTransactions ( block , state , pindex , blockPos ) )
return error ( " AcceptBlock() : ReceivedBlockTransactions failed " ) ;
return error ( " AcceptBlock() : ReceivedBlockTransactions failed " ) ;
} catch ( std : : runtime_error & e ) {
} catch ( std : : runtime_error & e ) {
return state . Abort ( _ ( " System error: " ) + e . what ( ) ) ;
return state . Abort ( std : : string ( " System error: " ) + e . what ( ) ) ;
}
}
return true ;
return true ;
@ -2719,10 +2719,12 @@ uint256 CPartialMerkleTree::ExtractMatches(std::vector<uint256> &vMatch) {
bool AbortNode ( const std : : string & strMessage ) {
bool AbortNode ( const std : : string & strMessage , const std : : string & userMessage ) {
strMiscWarning = strMessage ;
strMiscWarning = strMessage ;
LogPrintf ( " *** %s \n " , strMessage ) ;
LogPrintf ( " *** %s \n " , strMessage ) ;
uiInterface . ThreadSafeMessageBox ( strMessage , " " , CClientUIInterface : : MSG_ERROR ) ;
uiInterface . ThreadSafeMessageBox (
userMessage . empty ( ) ? _ ( " Error: A fatal internal error occured, see debug.log for details " ) : userMessage ,
" " , CClientUIInterface : : MSG_ERROR ) ;
StartShutdown ( ) ;
StartShutdown ( ) ;
return false ;
return false ;
}
}
@ -2733,7 +2735,7 @@ bool CheckDiskSpace(uint64_t nAdditionalBytes)
// Check for nMinDiskSpace bytes (currently 50MB)
// Check for nMinDiskSpace bytes (currently 50MB)
if ( nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes )
if ( nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes )
return AbortNode ( _ ( " Error: Disk space is low! " ) ) ;
return AbortNode ( " Disk space is low! " , _ ( " Error: Disk space is low! " ) ) ;
return true ;
return true ;
}
}
@ -3143,7 +3145,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
}
}
fclose ( fileIn ) ;
fclose ( fileIn ) ;
} catch ( std : : runtime_error & e ) {
} catch ( std : : runtime_error & e ) {
AbortNode ( _ ( " Error: s ystem error: " ) + e . what ( ) ) ;
AbortNode ( std : : string ( " S ystem error: " ) + e . what ( ) ) ;
}
}
if ( nLoaded > 0 )
if ( nLoaded > 0 )
LogPrintf ( " Loaded %i blocks from external file in %dms \n " , nLoaded , GetTimeMillis ( ) - nStart ) ;
LogPrintf ( " Loaded %i blocks from external file in %dms \n " , nLoaded , GetTimeMillis ( ) - nStart ) ;