aboutsummaryrefslogtreecommitdiff
path: root/src/cryptonote_core/blockchain.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-25 21:59:26 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2015-12-25 21:59:26 +0000
commit3cabdb5ef239fa1d1638d5233de882f59c787dc8 (patch)
tree7a22aae8275df6cdbd186903fce7f2ee1fff6a46 /src/cryptonote_core/blockchain.cpp
parentdb: throw when given a non txout_to_key output to add (diff)
downloadmonero-3cabdb5ef239fa1d1638d5233de882f59c787dc8.tar.xz
core: catch exceptions from get_output_key
This can happen when trying to find an amount that does not exist, and fixes a core test.
Diffstat (limited to 'src/cryptonote_core/blockchain.cpp')
-rw-r--r--src/cryptonote_core/blockchain.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index b83a5fd0e..64b7a5b2f 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -155,7 +155,15 @@ bool Blockchain::scan_outputkeys_for_indexes(const txin_to_key& tx_in_to_key, vi
if (!found)
{
- m_db->get_output_key(tx_in_to_key.amount, absolute_offsets, outputs);
+ try
+ {
+ m_db->get_output_key(tx_in_to_key.amount, absolute_offsets, outputs);
+ }
+ catch (...)
+ {
+ LOG_PRINT_L0("Output does not exist! amount = " << tx_in_to_key.amount);
+ return false;
+ }
}
else
{
@@ -167,7 +175,15 @@ bool Blockchain::scan_outputkeys_for_indexes(const txin_to_key& tx_in_to_key, vi
std::vector<output_data_t> add_outputs;
for (size_t i = outputs.size(); i < absolute_offsets.size(); i++)
add_offsets.push_back(absolute_offsets[i]);
- m_db->get_output_key(tx_in_to_key.amount, add_offsets, add_outputs);
+ try
+ {
+ m_db->get_output_key(tx_in_to_key.amount, add_offsets, add_outputs);
+ }
+ catch (...)
+ {
+ LOG_PRINT_L0("Output does not exist! amount = " << tx_in_to_key.amount);
+ return false;
+ }
outputs.insert(outputs.end(), add_outputs.begin(), add_outputs.end());
}
}