Skip to content

Commit fa69e3a

Browse files
author
MarcoFalke
committed
Remove unused MessageStartChars parameters from BlockManager methods
1 parent 44b05bf commit fa69e3a

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2212,7 +2212,7 @@ void PeerManagerImpl::ProcessGetBlockData(CNode& pfrom, Peer& peer, const CInv&
22122212
// Fast-path: in this case it is possible to serve the block directly from disk,
22132213
// as the network format matches the format on disk
22142214
std::vector<uint8_t> block_data;
2215-
if (!m_chainman.m_blockman.ReadRawBlockFromDisk(block_data, pindex->GetBlockPos(), m_chainparams.MessageStart())) {
2215+
if (!m_chainman.m_blockman.ReadRawBlockFromDisk(block_data, pindex->GetBlockPos())) {
22162216
assert(!"cannot load block from disk");
22172217
}
22182218
m_connman.PushMessage(&pfrom, msgMaker.Make(NetMsgType::BLOCK, Span{block_data}));

src/node/blockstorage.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ CBlockFileInfo* BlockManager::GetBlockFileInfo(size_t n)
476476
return &m_blockfile_info.at(n);
477477
}
478478

479-
bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart) const
479+
bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock) const
480480
{
481481
// Open history file to append
482482
AutoFile fileout{OpenUndoFile(pos)};
@@ -486,7 +486,7 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
486486

487487
// Write index header
488488
unsigned int nSize = GetSerializeSize(blockundo, CLIENT_VERSION);
489-
fileout << messageStart << nSize;
489+
fileout << GetParams().MessageStart() << nSize;
490490

491491
// Write undo data
492492
long fileOutPos = ftell(fileout.Get());
@@ -707,7 +707,7 @@ bool BlockManager::FindUndoPos(BlockValidationState& state, int nFile, FlatFileP
707707
return true;
708708
}
709709

710-
bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos, const CMessageHeader::MessageStartChars& messageStart) const
710+
bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
711711
{
712712
// Open history file to append
713713
CAutoFile fileout(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION);
@@ -717,7 +717,7 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos, const
717717

718718
// Write index header
719719
unsigned int nSize = GetSerializeSize(block, fileout.GetVersion());
720-
fileout << messageStart << nSize;
720+
fileout << GetParams().MessageStart() << nSize;
721721

722722
// Write block
723723
long fileOutPos = ftell(fileout.Get());
@@ -739,7 +739,7 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
739739
if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo, CLIENT_VERSION) + 40)) {
740740
return error("ConnectBlock(): FindUndoPos failed");
741741
}
742-
if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash(), GetParams().MessageStart())) {
742+
if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash())) {
743743
return FatalError(m_opts.notifications, state, "Failed to write undo data");
744744
}
745745
// rev files are written in block height order, whereas blk files are written as blocks come in (often out of order)
@@ -804,7 +804,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const CBlockIndex& index) co
804804
return true;
805805
}
806806

807-
bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos, const CMessageHeader::MessageStartChars& message_start) const
807+
bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos) const
808808
{
809809
FlatFilePos hpos = pos;
810810
hpos.nPos -= 8; // Seek back 8 bytes for meta header
@@ -819,10 +819,10 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
819819

820820
filein >> blk_start >> blk_size;
821821

822-
if (memcmp(blk_start, message_start, CMessageHeader::MESSAGE_START_SIZE)) {
822+
if (memcmp(blk_start, GetParams().MessageStart(), CMessageHeader::MESSAGE_START_SIZE)) {
823823
return error("%s: Block magic mismatch for %s: %s versus expected %s", __func__, pos.ToString(),
824824
HexStr(blk_start),
825-
HexStr(message_start));
825+
HexStr(GetParams().MessageStart()));
826826
}
827827

828828
if (blk_size > MAX_SIZE) {
@@ -857,7 +857,7 @@ FlatFilePos BlockManager::SaveBlockToDisk(const CBlock& block, int nHeight, CCha
857857
return FlatFilePos();
858858
}
859859
if (!position_known) {
860-
if (!WriteBlockToDisk(block, blockPos, GetParams().MessageStart())) {
860+
if (!WriteBlockToDisk(block, blockPos)) {
861861
m_opts.notifications.fatalError("Failed to write block");
862862
return FlatFilePos();
863863
}

src/node/blockstorage.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ class BlockManager
102102

103103
FILE* OpenUndoFile(const FlatFilePos& pos, bool fReadOnly = false) const;
104104

105-
bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos, const CMessageHeader::MessageStartChars& messageStart) const;
106-
bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart) const;
105+
bool WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const;
106+
bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock) const;
107107

108108
/* Calculate the block/rev files to delete based on height specified by user with RPC command pruneblockchain */
109109
void FindFilesToPruneManual(std::set<int>& setFilesToPrune, int nManualPruneHeight, int chain_tip_height);
@@ -252,7 +252,7 @@ class BlockManager
252252
/** Functions for disk access for blocks */
253253
bool ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) const;
254254
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex& index) const;
255-
bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos, const CMessageHeader::MessageStartChars& message_start) const;
255+
bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos) const;
256256

257257
bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& index) const;
258258

0 commit comments

Comments
 (0)