rpc: allow getting pruned blocks from gettransactions

and get them pruned in find_and_save_rings, since it does not need
the pruned data in the first place.

Also set decode_to_json to false where missing, we don't need this
either.
This commit is contained in:
moneromooo-monero 2018-04-04 10:03:16 +01:00 committed by wowario
parent 6d16e1abf4
commit 320db6c7b7
No known key found for this signature in database
GPG key ID: 24DCBE762DE9C111

View file

@ -5598,7 +5598,24 @@ bool wallet2::find_and_save_rings(bool force)
txs_hashes.push_back(txid); txs_hashes.push_back(txid);
} }
MDEBUG("Found " << std::to_string(txs_hashes.size()) << " transactions"); MDEBUG("Found " << std::to_string(req.txs_hashes.size()) << " transactions");
// get those transactions from the daemon
req.decode_as_json = false;
req.prune = true;
bool r;
{
const boost::lock_guard<boost::mutex> lock{m_daemon_rpc_mutex};
r = epee::net_utils::invoke_http_json("/gettransactions", req, res, m_http_client, rpc_timeout);
}
THROW_WALLET_EXCEPTION_IF(!r, error::no_connection_to_daemon, "gettransactions");
THROW_WALLET_EXCEPTION_IF(res.status == CORE_RPC_STATUS_BUSY, error::daemon_busy, "gettransactions");
THROW_WALLET_EXCEPTION_IF(res.status != CORE_RPC_STATUS_OK, error::wallet_internal_error, "gettransactions");
THROW_WALLET_EXCEPTION_IF(res.txs.size() != req.txs_hashes.size(), error::wallet_internal_error,
"daemon returned wrong response for gettransactions, wrong txs count = " +
std::to_string(res.txs.size()) + ", expected " + std::to_string(req.txs_hashes.size()));
MDEBUG("Scanning " << res.txs.size() << " transactions");
crypto::chacha_key key; crypto::chacha_key key;
generate_chacha_key_from_secret_keys(key); generate_chacha_key_from_secret_keys(key);
@ -8212,7 +8229,7 @@ std::string wallet2::get_spend_proof(const crypto::hash &txid, const std::string
COMMAND_RPC_GET_TRANSACTIONS::request req = AUTO_VAL_INIT(req); COMMAND_RPC_GET_TRANSACTIONS::request req = AUTO_VAL_INIT(req);
req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid)); req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
req.decode_as_json = false; req.decode_as_json = false;
req.prune = true; req.prune = false;
COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res); COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res);
bool r; bool r;
{ {
@ -8332,7 +8349,7 @@ bool wallet2::check_spend_proof(const crypto::hash &txid, const std::string &mes
COMMAND_RPC_GET_TRANSACTIONS::request req = AUTO_VAL_INIT(req); COMMAND_RPC_GET_TRANSACTIONS::request req = AUTO_VAL_INIT(req);
req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid)); req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txid));
req.decode_as_json = false; req.decode_as_json = false;
req.prune = true; req.prune = false;
COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res); COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res);
bool r; bool r;
{ {