mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-11 15:27:57 +00:00
Prevent crashes due to missing or corrupted blk????.dat records
In LoadExternalBlockFile(), errors are already caught... silently. Add a warning message, even though we do not abort the program due to load error.
This commit is contained in:
parent
f94b64c2f3
commit
8fe791e4e2
@ -2133,8 +2133,9 @@ bool LoadExternalBlockFile(FILE* fileIn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::exception &e)
|
catch (std::exception &e) {
|
||||||
{
|
printf("%s() : Deserialize or I/O error caught during load\n",
|
||||||
|
__PRETTY_FUNCTION__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("Loaded %i blocks from external file\n", nLoaded);
|
printf("Loaded %i blocks from external file\n", nLoaded);
|
||||||
|
15
src/main.h
15
src/main.h
@ -593,7 +593,13 @@ public:
|
|||||||
// Read transaction
|
// Read transaction
|
||||||
if (fseek(filein, pos.nTxPos, SEEK_SET) != 0)
|
if (fseek(filein, pos.nTxPos, SEEK_SET) != 0)
|
||||||
return error("CTransaction::ReadFromDisk() : fseek failed");
|
return error("CTransaction::ReadFromDisk() : fseek failed");
|
||||||
filein >> *this;
|
|
||||||
|
try {
|
||||||
|
filein >> *this;
|
||||||
|
}
|
||||||
|
catch (std::exception &e) {
|
||||||
|
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
// Return file pointer
|
// Return file pointer
|
||||||
if (pfileRet)
|
if (pfileRet)
|
||||||
@ -969,7 +975,12 @@ public:
|
|||||||
filein.nType |= SER_BLOCKHEADERONLY;
|
filein.nType |= SER_BLOCKHEADERONLY;
|
||||||
|
|
||||||
// Read block
|
// Read block
|
||||||
filein >> *this;
|
try {
|
||||||
|
filein >> *this;
|
||||||
|
}
|
||||||
|
catch (std::exception &e) {
|
||||||
|
return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__);
|
||||||
|
}
|
||||||
|
|
||||||
// Check the header
|
// Check the header
|
||||||
if (!CheckProofOfWork(GetHash(), nBits))
|
if (!CheckProofOfWork(GetHash(), nBits))
|
||||||
|
Loading…
Reference in New Issue
Block a user