simplewallet: lock idle scope in {im,ex}port_{key_images,outputs}

This ensures we can't get races
This commit is contained in:
moneromooo-monero 2017-12-20 14:21:50 +00:00
parent 1cc7451130
commit 586ee64209
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3

View File

@ -6046,6 +6046,7 @@ bool simple_wallet::export_key_images(const std::vector<std::string> &args)
try try
{ {
LOCK_IDLE_SCOPE();
if (!m_wallet->export_key_images(filename)) if (!m_wallet->export_key_images(filename))
{ {
fail_msg_writer() << tr("failed to save file ") << filename; fail_msg_writer() << tr("failed to save file ") << filename;
@ -6078,6 +6079,7 @@ bool simple_wallet::import_key_images(const std::vector<std::string> &args)
} }
std::string filename = args[0]; std::string filename = args[0];
LOCK_IDLE_SCOPE();
try try
{ {
uint64_t spent = 0, unspent = 0; uint64_t spent = 0, unspent = 0;
@ -6109,6 +6111,7 @@ bool simple_wallet::export_outputs(const std::vector<std::string> &args)
if (m_wallet->ask_password() && !get_and_verify_password()) { return true; } if (m_wallet->ask_password() && !get_and_verify_password()) { return true; }
std::string filename = args[0]; std::string filename = args[0];
LOCK_IDLE_SCOPE();
try try
{ {
std::vector<tools::wallet2::transfer_details> outs = m_wallet->export_outputs(); std::vector<tools::wallet2::transfer_details> outs = m_wallet->export_outputs();
@ -6207,6 +6210,7 @@ bool simple_wallet::import_outputs(const std::vector<std::string> &args)
boost::archive::binary_iarchive ar(iss); boost::archive::binary_iarchive ar(iss);
ar >> outputs; ar >> outputs;
} }
LOCK_IDLE_SCOPE();
size_t n_outputs = m_wallet->import_outputs(outputs); size_t n_outputs = m_wallet->import_outputs(outputs);
success_msg_writer() << boost::lexical_cast<std::string>(n_outputs) << " outputs imported"; success_msg_writer() << boost::lexical_cast<std::string>(n_outputs) << " outputs imported";
} }