Browse Source

Throw error in wallet if ReadBlockFromDisk fails

dev
Duke Leto 2 years ago
parent
commit
afd3f93e2e
  1. 16
      src/wallet/wallet.cpp

16
src/wallet/wallet.cpp

@ -1032,7 +1032,10 @@ int CWallet::VerifyAndSetInitialWitness(const CBlockIndex* pindex, bool witnessO
//Cycle through blocks and transactions building sapling tree until the commitment needed is reached
const CBlock* pblock;
CBlock block;
ReadBlockFromDisk(block, pblockindex, 1);
if (!ReadBlockFromDisk(block, pblockindex, 1)) {
throw std::runtime_error(
strprintf("Cannot read block height %d (%s) from disk", pindex->GetHeight(), pindex->GetBlockHash().GetHex()));
}
pblock = █
for (const CTransaction& tx : block.vtx) {
@ -1102,7 +1105,10 @@ void CWallet::BuildWitnessCache(const CBlockIndex* pindex, bool witnessOnly)
//Cycle through blocks and transactions building sapling tree until the commitment needed is reached
CBlock block;
ReadBlockFromDisk(block, pblockindex, 1);
if (!ReadBlockFromDisk(block, pblockindex, 1)) {
throw std::runtime_error(
strprintf("Cannot read block height %d (%s) from disk", pindex->GetHeight(), pindex->GetBlockHash().GetHex()));
}
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
@ -2721,7 +2727,11 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
CBlock block;
bool involvesMe = false;
ReadBlockFromDisk(block, pindex,1);
if (!ReadBlockFromDisk(block, pindex,1)) {
throw std::runtime_error(
strprintf("Cannot read block height %d (%s) from disk", pindex->GetHeight(), pindex->GetBlockHash().GetHex()));
}
BOOST_FOREACH(CTransaction& tx, block.vtx)
{
if (AddToWalletIfInvolvingMe(tx, &block, fUpdate)) {

Loading…
Cancel
Save