mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-01-17 18:40:09 +00:00
Merge pull request #3490
7e08e29 better std::exception logging for block/undo files (Philip Kaufmann)
This commit is contained in:
commit
6c19ca1f92
16
src/main.cpp
16
src/main.cpp
@ -883,11 +883,11 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
|||||||
fseek(file, postx.nTxOffset, SEEK_CUR);
|
fseek(file, postx.nTxOffset, SEEK_CUR);
|
||||||
file >> txOut;
|
file >> txOut;
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
|
return error("%s : Deserialize or I/O error - %s", __PRETTY_FUNCTION__, e.what());
|
||||||
}
|
}
|
||||||
hashBlock = header.GetHash();
|
hashBlock = header.GetHash();
|
||||||
if (txOut.GetHash() != hash)
|
if (txOut.GetHash() != hash)
|
||||||
return error("%s() : txid mismatch", __PRETTY_FUNCTION__);
|
return error("%s : txid mismatch", __PRETTY_FUNCTION__);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -936,7 +936,7 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos)
|
|||||||
// Open history file to append
|
// Open history file to append
|
||||||
CAutoFile fileout = CAutoFile(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION);
|
CAutoFile fileout = CAutoFile(OpenBlockFile(pos), SER_DISK, CLIENT_VERSION);
|
||||||
if (!fileout)
|
if (!fileout)
|
||||||
return error("WriteBlockToDisk() : OpenBlockFile failed");
|
return error("WriteBlockToDisk : OpenBlockFile failed");
|
||||||
|
|
||||||
// Write index header
|
// Write index header
|
||||||
unsigned int nSize = fileout.GetSerializeSize(block);
|
unsigned int nSize = fileout.GetSerializeSize(block);
|
||||||
@ -945,7 +945,7 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos)
|
|||||||
// Write block
|
// Write block
|
||||||
long fileOutPos = ftell(fileout);
|
long fileOutPos = ftell(fileout);
|
||||||
if (fileOutPos < 0)
|
if (fileOutPos < 0)
|
||||||
return error("WriteBlockToDisk() : ftell failed");
|
return error("WriteBlockToDisk : ftell failed");
|
||||||
pos.nPos = (unsigned int)fileOutPos;
|
pos.nPos = (unsigned int)fileOutPos;
|
||||||
fileout << block;
|
fileout << block;
|
||||||
|
|
||||||
@ -964,19 +964,19 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
|||||||
// Open history file to read
|
// Open history file to read
|
||||||
CAutoFile filein = CAutoFile(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
|
CAutoFile filein = CAutoFile(OpenBlockFile(pos, true), SER_DISK, CLIENT_VERSION);
|
||||||
if (!filein)
|
if (!filein)
|
||||||
return error("ReadBlockFromDisk(CBlock&, CDiskBlockPos&) : OpenBlockFile failed");
|
return error("ReadBlockFromDisk : OpenBlockFile failed");
|
||||||
|
|
||||||
// Read block
|
// Read block
|
||||||
try {
|
try {
|
||||||
filein >> block;
|
filein >> block;
|
||||||
}
|
}
|
||||||
catch (std::exception &e) {
|
catch (std::exception &e) {
|
||||||
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
|
return error("%s : Deserialize or I/O error - %s", __PRETTY_FUNCTION__, e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the header
|
// Check the header
|
||||||
if (!CheckProofOfWork(block.GetHash(), block.nBits))
|
if (!CheckProofOfWork(block.GetHash(), block.nBits))
|
||||||
return error("ReadBlockFromDisk(CBlock&, CDiskBlockPos&) : errors in block header");
|
return error("ReadBlockFromDisk : Errors in block header");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2876,7 +2876,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (std::exception &e) {
|
} catch (std::exception &e) {
|
||||||
LogPrintf("%s() : Deserialize or I/O error caught during load\n", __PRETTY_FUNCTION__);
|
LogPrintf("%s : Deserialize or I/O error - %s", __PRETTY_FUNCTION__, e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fileIn);
|
fclose(fileIn);
|
||||||
|
10
src/main.h
10
src/main.h
@ -336,7 +336,7 @@ public:
|
|||||||
// Open history file to append
|
// Open history file to append
|
||||||
CAutoFile fileout = CAutoFile(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
|
CAutoFile fileout = CAutoFile(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
|
||||||
if (!fileout)
|
if (!fileout)
|
||||||
return error("CBlockUndo::WriteToDisk() : OpenUndoFile failed");
|
return error("CBlockUndo::WriteToDisk : OpenUndoFile failed");
|
||||||
|
|
||||||
// Write index header
|
// Write index header
|
||||||
unsigned int nSize = fileout.GetSerializeSize(*this);
|
unsigned int nSize = fileout.GetSerializeSize(*this);
|
||||||
@ -345,7 +345,7 @@ public:
|
|||||||
// Write undo data
|
// Write undo data
|
||||||
long fileOutPos = ftell(fileout);
|
long fileOutPos = ftell(fileout);
|
||||||
if (fileOutPos < 0)
|
if (fileOutPos < 0)
|
||||||
return error("CBlockUndo::WriteToDisk() : ftell failed");
|
return error("CBlockUndo::WriteToDisk : ftell failed");
|
||||||
pos.nPos = (unsigned int)fileOutPos;
|
pos.nPos = (unsigned int)fileOutPos;
|
||||||
fileout << *this;
|
fileout << *this;
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ public:
|
|||||||
// Open history file to read
|
// Open history file to read
|
||||||
CAutoFile filein = CAutoFile(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION);
|
CAutoFile filein = CAutoFile(OpenUndoFile(pos, true), SER_DISK, CLIENT_VERSION);
|
||||||
if (!filein)
|
if (!filein)
|
||||||
return error("CBlockUndo::ReadFromDisk() : OpenBlockFile failed");
|
return error("CBlockUndo::ReadFromDisk : OpenBlockFile failed");
|
||||||
|
|
||||||
// Read block
|
// Read block
|
||||||
uint256 hashChecksum;
|
uint256 hashChecksum;
|
||||||
@ -377,7 +377,7 @@ public:
|
|||||||
filein >> hashChecksum;
|
filein >> hashChecksum;
|
||||||
}
|
}
|
||||||
catch (std::exception &e) {
|
catch (std::exception &e) {
|
||||||
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
|
return error("%s : Deserialize or I/O error - %s", __PRETTY_FUNCTION__, e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify checksum
|
// Verify checksum
|
||||||
@ -385,7 +385,7 @@ public:
|
|||||||
hasher << hashBlock;
|
hasher << hashBlock;
|
||||||
hasher << *this;
|
hasher << *this;
|
||||||
if (hashChecksum != hasher.GetHash())
|
if (hashChecksum != hasher.GetHash())
|
||||||
return error("CBlockUndo::ReadFromDisk() : checksum mismatch");
|
return error("CBlockUndo::ReadFromDisk : Checksum mismatch");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user