@@ -662,7 +662,7 @@ bool BlockManager::ReadBlockUndo(CBlockUndo& blockundo, const CBlockIndex& index
662
662
// Open history file to read
663
663
AutoFile filein{OpenUndoFile (pos, true )};
664
664
if (filein.IsNull ()) {
665
- LogError (" OpenUndoFile failed for %s" , pos.ToString ());
665
+ LogError (" OpenUndoFile failed for %s while reading block undo " , pos.ToString ());
666
666
return false ;
667
667
}
668
668
@@ -678,11 +678,11 @@ bool BlockManager::ReadBlockUndo(CBlockUndo& blockundo, const CBlockIndex& index
678
678
679
679
// Verify checksum
680
680
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 ());
682
682
return false ;
683
683
}
684
684
} 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 ());
686
686
return false ;
687
687
}
688
688
@@ -935,15 +935,15 @@ bool BlockManager::WriteBlockUndo(const CBlockUndo& blockundo, BlockValidationSt
935
935
FlatFilePos pos;
936
936
const unsigned int blockundo_size{static_cast <unsigned int >(GetSerializeSize (blockundo))};
937
937
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 () );
939
939
return false ;
940
940
}
941
941
942
942
{
943
943
// Open history file to append
944
944
AutoFile fileout{OpenUndoFile (pos)};
945
945
if (fileout.IsNull ()) {
946
- LogError (" OpenUndoFile failed" );
946
+ LogError (" OpenUndoFile failed for %s while writing block undo " , pos. ToString () );
947
947
return FatalError (m_opts.notifications , state, _ (" Failed to write undo data." ));
948
948
}
949
949
@@ -998,27 +998,27 @@ bool BlockManager::ReadBlock(CBlock& block, const FlatFilePos& pos) const
998
998
// Open history file to read
999
999
AutoFile filein{OpenBlockFile (pos, true )};
1000
1000
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 ());
1002
1002
return false ;
1003
1003
}
1004
1004
1005
1005
try {
1006
1006
// Read block
1007
1007
filein >> TX_WITH_WITNESS (block);
1008
1008
} 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 ());
1010
1010
return false ;
1011
1011
}
1012
1012
1013
1013
// Check the header
1014
1014
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 ());
1016
1016
return false ;
1017
1017
}
1018
1018
1019
1019
// Signet only: check block solution
1020
1020
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 ());
1022
1022
return false ;
1023
1023
}
1024
1024
@@ -1033,7 +1033,7 @@ bool BlockManager::ReadBlock(CBlock& block, const CBlockIndex& index) const
1033
1033
return false ;
1034
1034
}
1035
1035
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 ());
1037
1037
return false ;
1038
1038
}
1039
1039
return true ;
@@ -1045,13 +1045,13 @@ bool BlockManager::ReadRawBlock(std::vector<uint8_t>& block, const FlatFilePos&
1045
1045
// If nPos is less than 8 the pos is null and we don't have the block data
1046
1046
// Return early to prevent undefined behavior of unsigned int underflow
1047
1047
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 ());
1049
1049
return false ;
1050
1050
}
1051
1051
hpos.nPos -= 8 ; // Seek back 8 bytes for meta header
1052
1052
AutoFile filein{OpenBlockFile (hpos, true )};
1053
1053
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 ());
1055
1055
return false ;
1056
1056
}
1057
1057
@@ -1062,22 +1062,21 @@ bool BlockManager::ReadRawBlock(std::vector<uint8_t>& block, const FlatFilePos&
1062
1062
filein >> blk_start >> blk_size;
1063
1063
1064
1064
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 ()));
1068
1067
return false ;
1069
1068
}
1070
1069
1071
1070
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);
1074
1073
return false ;
1075
1074
}
1076
1075
1077
1076
block.resize (blk_size); // Zeroing of memory is intentional here
1078
1077
filein.read (MakeWritableByteSpan (block));
1079
1078
} 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 ());
1081
1080
return false ;
1082
1081
}
1083
1082
@@ -1089,12 +1088,12 @@ FlatFilePos BlockManager::WriteBlock(const CBlock& block, int nHeight)
1089
1088
const unsigned int block_size{static_cast <unsigned int >(GetSerializeSize (TX_WITH_WITNESS (block)))};
1090
1089
FlatFilePos pos{FindNextBlockPos (block_size + STORAGE_HEADER_BYTES, nHeight, block.GetBlockTime ())};
1091
1090
if (pos.IsNull ()) {
1092
- LogError (" FindNextBlockPos failed" );
1091
+ LogError (" FindNextBlockPos failed for %s while writing block " , pos. ToString () );
1093
1092
return FlatFilePos ();
1094
1093
}
1095
1094
AutoFile fileout{OpenBlockFile (pos)};
1096
1095
if (fileout.IsNull ()) {
1097
- LogError (" OpenBlockFile failed" );
1096
+ LogError (" OpenBlockFile failed for %s while writing block " , pos. ToString () );
1098
1097
m_opts.notifications .fatalError (_ (" Failed to write block." ));
1099
1098
return FlatFilePos ();
1100
1099
}
0 commit comments