@@ -1146,7 +1146,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
1146
1146
// CBlock and CBlockIndex
1147
1147
//
1148
1148
1149
- bool WriteBlockToDisk (CBlock& block, CDiskBlockPos& pos)
1149
+ bool WriteBlockToDisk (CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart )
1150
1150
{
1151
1151
// Open history file to append
1152
1152
CAutoFile fileout (OpenBlockFile (pos), SER_DISK, CLIENT_VERSION);
@@ -1155,7 +1155,7 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos)
1155
1155
1156
1156
// Write index header
1157
1157
unsigned int nSize = fileout.GetSerializeSize (block);
1158
- fileout << FLATDATA (Params (). MessageStart () ) << nSize;
1158
+ fileout << FLATDATA (messageStart ) << nSize;
1159
1159
1160
1160
// Write block
1161
1161
long fileOutPos = ftell (fileout.Get ());
@@ -1509,7 +1509,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
1509
1509
1510
1510
namespace {
1511
1511
1512
- bool UndoWriteToDisk (const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock)
1512
+ bool UndoWriteToDisk (const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart )
1513
1513
{
1514
1514
// Open history file to append
1515
1515
CAutoFile fileout (OpenUndoFile (pos), SER_DISK, CLIENT_VERSION);
@@ -1518,7 +1518,7 @@ bool UndoWriteToDisk(const CBlockUndo& blockundo, CDiskBlockPos& pos, const uint
1518
1518
1519
1519
// Write index header
1520
1520
unsigned int nSize = fileout.GetSerializeSize (blockundo);
1521
- fileout << FLATDATA (Params (). MessageStart () ) << nSize;
1521
+ fileout << FLATDATA (messageStart ) << nSize;
1522
1522
1523
1523
// Write undo data
1524
1524
long fileOutPos = ftell (fileout.Get ());
@@ -1918,7 +1918,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
1918
1918
CDiskBlockPos pos;
1919
1919
if (!FindUndoPos (state, pindex->nFile , pos, ::GetSerializeSize (blockundo, SER_DISK, CLIENT_VERSION) + 40 ))
1920
1920
return error (" ConnectBlock(): FindUndoPos failed" );
1921
- if (!UndoWriteToDisk (blockundo, pos, pindex->pprev ->GetBlockHash ()))
1921
+ if (!UndoWriteToDisk (blockundo, pos, pindex->pprev ->GetBlockHash (), chainparams. MessageStart () ))
1922
1922
return AbortNode (state, " Failed to write undo data" );
1923
1923
1924
1924
// update nUndoPos in block index
@@ -2841,6 +2841,7 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
2841
2841
2842
2842
bool AcceptBlock (CBlock& block, CValidationState& state, CBlockIndex** ppindex, CDiskBlockPos* dbp)
2843
2843
{
2844
+ const CChainParams& chainparams = Params ();
2844
2845
AssertLockHeld (cs_main);
2845
2846
2846
2847
CBlockIndex *&pindex = *ppindex;
@@ -2876,7 +2877,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
2876
2877
if (!FindBlockPos (state, blockPos, nBlockSize+8 , nHeight, block.GetBlockTime (), dbp != NULL ))
2877
2878
return error (" AcceptBlock(): FindBlockPos failed" );
2878
2879
if (dbp == NULL )
2879
- if (!WriteBlockToDisk (block, blockPos))
2880
+ if (!WriteBlockToDisk (block, blockPos, chainparams. MessageStart () ))
2880
2881
AbortNode (state, " Failed to write block" );
2881
2882
if (!ReceivedBlockTransactions (block, state, pindex, blockPos))
2882
2883
return error (" AcceptBlock(): ReceivedBlockTransactions failed" );
@@ -3366,6 +3367,7 @@ bool LoadBlockIndex()
3366
3367
3367
3368
3368
3369
bool InitBlockIndex () {
3370
+ const CChainParams& chainparams = Params ();
3369
3371
LOCK (cs_main);
3370
3372
// Check whether we're already initialized
3371
3373
if (chainActive.Genesis () != NULL )
@@ -3386,7 +3388,7 @@ bool InitBlockIndex() {
3386
3388
CValidationState state;
3387
3389
if (!FindBlockPos (state, blockPos, nBlockSize+8 , 0 , block.GetBlockTime ()))
3388
3390
return error (" LoadBlockIndex(): FindBlockPos failed" );
3389
- if (!WriteBlockToDisk (block, blockPos))
3391
+ if (!WriteBlockToDisk (block, blockPos, chainparams. MessageStart () ))
3390
3392
return error (" LoadBlockIndex(): writing genesis block to disk failed" );
3391
3393
CBlockIndex *pindex = AddToBlockIndex (block);
3392
3394
if (!ReceivedBlockTransactions (block, state, pindex, blockPos))
0 commit comments