@@ -662,7 +662,7 @@ bool BlockManager::ReadBlockUndo(CBlockUndo& blockundo, const CBlockIndex& index
662662 // Open history file to read
663663 AutoFile filein{OpenUndoFile (pos, true )};
664664 if (filein.IsNull ()) {
665- LogError (" OpenUndoFile failed for %s" , pos.ToString ());
665+ LogError (" OpenUndoFile failed for %s while reading block undo " , pos.ToString ());
666666 return false ;
667667 }
668668
@@ -678,11 +678,11 @@ bool BlockManager::ReadBlockUndo(CBlockUndo& blockundo, const CBlockIndex& index
678678
679679 // Verify checksum
680680 if (hashChecksum != verifier.GetHash ()) {
681- LogError (" %s: Checksum mismatch at %s\n " , __func__ , pos.ToString ());
681+ LogError (" Checksum mismatch at %s while reading block undo " , pos.ToString ());
682682 return false ;
683683 }
684684 } catch (const std::exception& e) {
685- LogError (" %s: Deserialize or I/O error - %s at %s\n " , __func__ , e.what (), pos.ToString ());
685+ LogError (" Deserialize or I/O error - %s at %s while reading block undo " , e.what (), pos.ToString ());
686686 return false ;
687687 }
688688
@@ -935,15 +935,15 @@ bool BlockManager::WriteBlockUndo(const CBlockUndo& blockundo, BlockValidationSt
935935 FlatFilePos pos;
936936 const unsigned int blockundo_size{static_cast <unsigned int >(GetSerializeSize (blockundo))};
937937 if (!FindUndoPos (state, block.nFile , pos, blockundo_size + UNDO_DATA_DISK_OVERHEAD)) {
938- LogError (" FindUndoPos failed" );
938+ LogError (" FindUndoPos failed for %s while writing block undo " , pos. ToString () );
939939 return false ;
940940 }
941941
942942 {
943943 // Open history file to append
944944 AutoFile fileout{OpenUndoFile (pos)};
945945 if (fileout.IsNull ()) {
946- LogError (" OpenUndoFile failed" );
946+ LogError (" OpenUndoFile failed for %s while writing block undo " , pos. ToString () );
947947 return FatalError (m_opts.notifications , state, _ (" Failed to write undo data." ));
948948 }
949949
@@ -998,27 +998,27 @@ bool BlockManager::ReadBlock(CBlock& block, const FlatFilePos& pos) const
998998 // Open history file to read
999999 AutoFile filein{OpenBlockFile (pos, true )};
10001000 if (filein.IsNull ()) {
1001- LogError (" %s: OpenBlockFile failed for %s\n " , __func__ , pos.ToString ());
1001+ LogError (" OpenBlockFile failed for %s while reading block " , pos.ToString ());
10021002 return false ;
10031003 }
10041004
10051005 try {
10061006 // Read block
10071007 filein >> TX_WITH_WITNESS (block);
10081008 } catch (const std::exception& e) {
1009- LogError (" %s: Deserialize or I/O error - %s at %s\n " , __func__ , e.what (), pos.ToString ());
1009+ LogError (" Deserialize or I/O error - %s at %s while reading block " , e.what (), pos.ToString ());
10101010 return false ;
10111011 }
10121012
10131013 // Check the header
10141014 if (!CheckProofOfWork (block.GetHash (), block.nBits , GetConsensus ())) {
1015- LogError (" %s: Errors in block header at %s\n " , __func__ , pos.ToString ());
1015+ LogError (" Errors in block header at %s while reading block " , pos.ToString ());
10161016 return false ;
10171017 }
10181018
10191019 // Signet only: check block solution
10201020 if (GetConsensus ().signet_blocks && !CheckSignetBlockSolution (block, GetConsensus ())) {
1021- LogError (" %s: Errors in block solution at %s\n " , __func__ , pos.ToString ());
1021+ LogError (" Errors in block solution at %s while reading block " , pos.ToString ());
10221022 return false ;
10231023 }
10241024
@@ -1033,7 +1033,7 @@ bool BlockManager::ReadBlock(CBlock& block, const CBlockIndex& index) const
10331033 return false ;
10341034 }
10351035 if (block.GetHash () != index.GetBlockHash ()) {
1036- LogError (" %s: GetHash() doesn't match index for %s at %s\n " , __func__ , index.ToString (), block_pos.ToString ());
1036+ LogError (" GetHash() doesn't match index for %s at %s while reading block " , index.ToString (), block_pos.ToString ());
10371037 return false ;
10381038 }
10391039 return true ;
@@ -1045,13 +1045,13 @@ bool BlockManager::ReadRawBlock(std::vector<uint8_t>& block, const FlatFilePos&
10451045 // If nPos is less than 8 the pos is null and we don't have the block data
10461046 // Return early to prevent undefined behavior of unsigned int underflow
10471047 if (hpos.nPos < 8 ) {
1048- LogError (" %s: OpenBlockFile failed for %s \n " , __func__ , pos.ToString ());
1048+ LogError (" Failed for %s while reading raw block " , pos.ToString ());
10491049 return false ;
10501050 }
10511051 hpos.nPos -= 8 ; // Seek back 8 bytes for meta header
10521052 AutoFile filein{OpenBlockFile (hpos, true )};
10531053 if (filein.IsNull ()) {
1054- LogError (" %s: OpenBlockFile failed for %s\n " , __func__ , pos.ToString ());
1054+ LogError (" OpenBlockFile failed for %s while reading raw block " , pos.ToString ());
10551055 return false ;
10561056 }
10571057
@@ -1062,22 +1062,21 @@ bool BlockManager::ReadRawBlock(std::vector<uint8_t>& block, const FlatFilePos&
10621062 filein >> blk_start >> blk_size;
10631063
10641064 if (blk_start != GetParams ().MessageStart ()) {
1065- LogError (" %s: Block magic mismatch for %s: %s versus expected %s\n " , __func__, pos.ToString (),
1066- HexStr (blk_start),
1067- HexStr (GetParams ().MessageStart ()));
1065+ LogError (" Block magic mismatch for %s: %s versus expected %s while reading raw block" ,
1066+ pos.ToString (), HexStr (blk_start), HexStr (GetParams ().MessageStart ()));
10681067 return false ;
10691068 }
10701069
10711070 if (blk_size > MAX_SIZE) {
1072- LogError (" %s: Block data is larger than maximum deserialization size for %s: %s versus %s\n " , __func__, pos. ToString () ,
1073- blk_size, MAX_SIZE);
1071+ LogError (" Block data is larger than maximum deserialization size for %s: %s versus %s while reading raw block " ,
1072+ pos. ToString (), blk_size, MAX_SIZE);
10741073 return false ;
10751074 }
10761075
10771076 block.resize (blk_size); // Zeroing of memory is intentional here
10781077 filein.read (MakeWritableByteSpan (block));
10791078 } catch (const std::exception& e) {
1080- LogError (" %s: Read from block file failed: %s for %s\n " , __func__ , e.what (), pos.ToString ());
1079+ LogError (" Read from block file failed: %s for %s while reading raw block " , e.what (), pos.ToString ());
10811080 return false ;
10821081 }
10831082
@@ -1089,12 +1088,12 @@ FlatFilePos BlockManager::WriteBlock(const CBlock& block, int nHeight)
10891088 const unsigned int block_size{static_cast <unsigned int >(GetSerializeSize (TX_WITH_WITNESS (block)))};
10901089 FlatFilePos pos{FindNextBlockPos (block_size + STORAGE_HEADER_BYTES, nHeight, block.GetBlockTime ())};
10911090 if (pos.IsNull ()) {
1092- LogError (" FindNextBlockPos failed" );
1091+ LogError (" FindNextBlockPos failed for %s while writing block " , pos. ToString () );
10931092 return FlatFilePos ();
10941093 }
10951094 AutoFile fileout{OpenBlockFile (pos)};
10961095 if (fileout.IsNull ()) {
1097- LogError (" OpenBlockFile failed" );
1096+ LogError (" OpenBlockFile failed for %s while writing block " , pos. ToString () );
10981097 m_opts.notifications .fatalError (_ (" Failed to write block." ));
10991098 return FlatFilePos ();
11001099 }
0 commit comments