Mercurial > hg > bitcoin
changeset 2665:4766c15995b7 draft
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.
author | Jeff Garzik <jgarzik@exmulti.com> |
---|---|
date | Tue, 22 May 2012 15:23:17 -0400 |
parents | 78df75bacef1 |
children | 3c868a1b2296 |
files | src/main.cpp src/main.h |
diffstat | 2 files changed, 16 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main.cpp +++ b/src/main.cpp @@ -2133,8 +2133,9 @@ } } } - 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);
--- a/src/main.h +++ b/src/main.h @@ -593,7 +593,13 @@ // Read transaction if (fseek(filein, pos.nTxPos, SEEK_SET) != 0) 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 if (pfileRet) @@ -969,7 +975,12 @@ filein.nType |= SER_BLOCKHEADERONLY; // Read block - filein >> *this; + try { + filein >> *this; + } + catch (std::exception &e) { + return error("%s() : deserialize or I/O error", __PRETTY_FUNCTION__); + } // Check the header if (!CheckProofOfWork(GetHash(), nBits))