scripted-diff: Replace error() with LogError()

This fixes the log output when -logsourcelocations is used.

Also, instead of 'ERROR:', the log will now say '[error]', like other
errors logged with LogError.

-BEGIN VERIFY SCRIPT-
 sed -i --regexp-extended 's!  error\("([^"]+)"!  LogError("\1\\n"!g' $( git grep -l '  error(' ./src/ )
-END VERIFY SCRIPT-
This commit is contained in:
MarcoFalke
2024-01-11 19:43:27 +01:00
parent fa808fb749
commit fad0335517
13 changed files with 97 additions and 97 deletions

View File

@@ -131,13 +131,13 @@ bool BlockTreeDB::LoadBlockIndexGuts(const Consensus::Params& consensusParams, s
pindexNew->nTx = diskindex.nTx;
if (!CheckProofOfWork(pindexNew->GetBlockHash(), pindexNew->nBits, consensusParams)) {
error("%s: CheckProofOfWork failed: %s", __func__, pindexNew->ToString());
LogError("%s: CheckProofOfWork failed: %s\n", __func__, pindexNew->ToString());
return false;
}
pcursor->Next();
} else {
error("%s: failed to read value", __func__);
LogError("%s: failed to read value\n", __func__);
return false;
}
} else {
@@ -434,7 +434,7 @@ bool BlockManager::LoadBlockIndex(const std::optional<uint256>& snapshot_blockha
for (CBlockIndex* pindex : vSortedByHeight) {
if (m_interrupt) return false;
if (previous_index && pindex->nHeight > previous_index->nHeight + 1) {
error("%s: block index is non-contiguous, index of height %d missing", __func__, previous_index->nHeight + 1);
LogError("%s: block index is non-contiguous, index of height %d missing\n", __func__, previous_index->nHeight + 1);
return false;
}
previous_index = pindex;
@@ -674,7 +674,7 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
// Open history file to append
AutoFile fileout{OpenUndoFile(pos)};
if (fileout.IsNull()) {
error("%s: OpenUndoFile failed", __func__);
LogError("%s: OpenUndoFile failed\n", __func__);
return false;
}
@@ -685,7 +685,7 @@ bool BlockManager::UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos
// Write undo data
long fileOutPos = ftell(fileout.Get());
if (fileOutPos < 0) {
error("%s: ftell failed", __func__);
LogError("%s: ftell failed\n", __func__);
return false;
}
pos.nPos = (unsigned int)fileOutPos;
@@ -705,14 +705,14 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
const FlatFilePos pos{WITH_LOCK(::cs_main, return index.GetUndoPos())};
if (pos.IsNull()) {
error("%s: no undo data available", __func__);
LogError("%s: no undo data available\n", __func__);
return false;
}
// Open history file to read
AutoFile filein{OpenUndoFile(pos, true)};
if (filein.IsNull()) {
error("%s: OpenUndoFile failed", __func__);
LogError("%s: OpenUndoFile failed\n", __func__);
return false;
}
@@ -724,13 +724,13 @@ bool BlockManager::UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex& in
verifier >> blockundo;
filein >> hashChecksum;
} catch (const std::exception& e) {
error("%s: Deserialize or I/O error - %s", __func__, e.what());
LogError("%s: Deserialize or I/O error - %s\n", __func__, e.what());
return false;
}
// Verify checksum
if (hashChecksum != verifier.GetHash()) {
error("%s: Checksum mismatch", __func__);
LogError("%s: Checksum mismatch\n", __func__);
return false;
}
@@ -974,7 +974,7 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
// Open history file to append
AutoFile fileout{OpenBlockFile(pos)};
if (fileout.IsNull()) {
error("WriteBlockToDisk: OpenBlockFile failed");
LogError("WriteBlockToDisk: OpenBlockFile failed\n");
return false;
}
@@ -985,7 +985,7 @@ bool BlockManager::WriteBlockToDisk(const CBlock& block, FlatFilePos& pos) const
// Write block
long fileOutPos = ftell(fileout.Get());
if (fileOutPos < 0) {
error("WriteBlockToDisk: ftell failed");
LogError("WriteBlockToDisk: ftell failed\n");
return false;
}
pos.nPos = (unsigned int)fileOutPos;
@@ -1004,7 +1004,7 @@ bool BlockManager::WriteUndoDataForBlock(const CBlockUndo& blockundo, BlockValid
if (block.GetUndoPos().IsNull()) {
FlatFilePos _pos;
if (!FindUndoPos(state, block.nFile, _pos, ::GetSerializeSize(blockundo) + 40)) {
error("ConnectBlock(): FindUndoPos failed");
LogError("ConnectBlock(): FindUndoPos failed\n");
return false;
}
if (!UndoWriteToDisk(blockundo, _pos, block.pprev->GetBlockHash())) {
@@ -1043,7 +1043,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
// Open history file to read
AutoFile filein{OpenBlockFile(pos, true)};
if (filein.IsNull()) {
error("ReadBlockFromDisk: OpenBlockFile failed for %s", pos.ToString());
LogError("ReadBlockFromDisk: OpenBlockFile failed for %s\n", pos.ToString());
return false;
}
@@ -1051,19 +1051,19 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const FlatFilePos& pos) cons
try {
filein >> TX_WITH_WITNESS(block);
} catch (const std::exception& e) {
error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
LogError("%s: Deserialize or I/O error - %s at %s\n", __func__, e.what(), pos.ToString());
return false;
}
// Check the header
if (!CheckProofOfWork(block.GetHash(), block.nBits, GetConsensus())) {
error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
LogError("ReadBlockFromDisk: Errors in block header at %s\n", pos.ToString());
return false;
}
// Signet only: check block solution
if (GetConsensus().signet_blocks && !CheckSignetBlockSolution(block, GetConsensus())) {
error("ReadBlockFromDisk: Errors in block solution at %s", pos.ToString());
LogError("ReadBlockFromDisk: Errors in block solution at %s\n", pos.ToString());
return false;
}
@@ -1078,7 +1078,7 @@ bool BlockManager::ReadBlockFromDisk(CBlock& block, const CBlockIndex& index) co
return false;
}
if (block.GetHash() != index.GetBlockHash()) {
error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
LogError("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s\n",
index.ToString(), block_pos.ToString());
return false;
}
@@ -1091,7 +1091,7 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
hpos.nPos -= 8; // Seek back 8 bytes for meta header
AutoFile filein{OpenBlockFile(hpos, true)};
if (filein.IsNull()) {
error("%s: OpenBlockFile failed for %s", __func__, pos.ToString());
LogError("%s: OpenBlockFile failed for %s\n", __func__, pos.ToString());
return false;
}
@@ -1102,14 +1102,14 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
filein >> blk_start >> blk_size;
if (blk_start != GetParams().MessageStart()) {
error("%s: Block magic mismatch for %s: %s versus expected %s", __func__, pos.ToString(),
LogError("%s: Block magic mismatch for %s: %s versus expected %s\n", __func__, pos.ToString(),
HexStr(blk_start),
HexStr(GetParams().MessageStart()));
return false;
}
if (blk_size > MAX_SIZE) {
error("%s: Block data is larger than maximum deserialization size for %s: %s versus %s", __func__, pos.ToString(),
LogError("%s: Block data is larger than maximum deserialization size for %s: %s versus %s\n", __func__, pos.ToString(),
blk_size, MAX_SIZE);
return false;
}
@@ -1117,7 +1117,7 @@ bool BlockManager::ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatF
block.resize(blk_size); // Zeroing of memory is intentional here
filein.read(MakeWritableByteSpan(block));
} catch (const std::exception& e) {
error("%s: Read from block file failed: %s for %s", __func__, e.what(), pos.ToString());
LogError("%s: Read from block file failed: %s for %s\n", __func__, e.what(), pos.ToString());
return false;
}
@@ -1138,7 +1138,7 @@ FlatFilePos BlockManager::SaveBlockToDisk(const CBlock& block, int nHeight, cons
nBlockSize += static_cast<unsigned int>(BLOCK_SERIALIZATION_HEADER_SIZE);
}
if (!FindBlockPos(blockPos, nBlockSize, nHeight, block.GetBlockTime(), position_known)) {
error("%s: FindBlockPos failed", __func__);
LogError("%s: FindBlockPos failed\n", __func__);
return FlatFilePos();
}
if (!position_known) {