Changes after review

This commit is contained in:
Jack Grigg
2016-09-01 11:38:43 +12:00
parent 0736fa14fc
commit 32a103aab7
6 changed files with 26 additions and 10 deletions

View File

@@ -172,7 +172,7 @@ TEST(wallet_tests, set_invalid_note_addrs_in_cwallettx) {
CNoteData nd {sk.address(), uint256()};
noteData[jsoutpt] = nd;
EXPECT_THROW(wtx.SetNoteData(noteData), std::runtime_error);
EXPECT_THROW(wtx.SetNoteData(noteData), std::logic_error);
}
TEST(wallet_tests, find_note_in_tx) {

View File

@@ -601,6 +601,8 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
for (std::pair<const uint256, CWalletTx>& wtxItem : mapWallet) {
for (mapNoteData_t::value_type& item : wtxItem.second.mapNoteData) {
CNoteData* nd = &(item.second);
// Check the validity of the cache
assert(nWitnessCacheSize >= nd->witnesses.size());
// Copy the witness for the previous block if we have one
if (nd->witnesses.size() > 0) {
nd->witnesses.push_front(nd->witnesses.front());
@@ -1060,8 +1062,12 @@ mapNoteData_t CWallet::FindMyNotes(const CTransaction& tx) const
CNoteData nd {address, note.nullifier(key)};
noteData.insert(std::make_pair(jsoutpt, nd));
break;
} catch (const std::exception &) {
} catch (const std::runtime_error &) {
// Couldn't decrypt with this spending key
} catch (const std::exception &exc) {
// Unexpected failure
LogPrintf("FindMyNotes(): Unexpected error while testing decrypt:\n");
LogPrintf("%s\n", exc.what());
}
}
}
@@ -1252,7 +1258,7 @@ void CWalletTx::SetNoteData(mapNoteData_t &noteData)
} else {
// If FindMyNotes() was used to obtain noteData,
// this should never happen
throw std::runtime_error("CWalletTc::SetNoteData(): Invalid note");
throw std::logic_error("CWalletTx::SetNoteData(): Invalid note");
}
}
}

View File

@@ -55,7 +55,8 @@ static const CAmount nHighTransactionMaxFeeWarning = 100 * nHighTransactionFeeWa
//! Largest (in bytes) free transaction we're willing to create
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
//! Size of witness cache
// Should be large enough that we can expect to never reorg beyond our cache.
// Should be large enough that we can expect not to reorg beyond our cache
// unless there is some exceptional network disruption.
static const unsigned int WITNESS_CACHE_SIZE = COINBASE_MATURITY;
class CAccountingEntry;