@@ -1250,7 +1250,7 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std
1250
1250
m_original_keys_available(false),
1251
1251
m_message_store(http_client_factory->create()),
1252
1252
m_key_device_type(hw::device::device_type::SOFTWARE),
1253
- m_ring_history_saved(false ),
1253
+ m_ring_history_saved(true ),
1254
1254
m_ringdb(),
1255
1255
m_last_block_reward(0),
1256
1256
m_unattended(unattended),
@@ -6520,15 +6520,6 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass
6520
6520
if (get_num_subaddress_accounts() == 0)
6521
6521
add_subaddress_account(tr("Primary account"));
6522
6522
6523
- try
6524
- {
6525
- find_and_save_rings(false);
6526
- }
6527
- catch (const std::exception &e)
6528
- {
6529
- MERROR("Failed to save rings, will try again next time");
6530
- }
6531
-
6532
6523
try
6533
6524
{
6534
6525
if (use_fs)
@@ -8918,67 +8909,11 @@ bool wallet2::unset_ring(const crypto::hash &txid)
8918
8909
8919
8910
bool wallet2::find_and_save_rings(bool force)
8920
8911
{
8921
- if (!force && m_ring_history_saved)
8922
- return true;
8923
- if (!m_ringdb)
8924
- return false;
8925
-
8926
- COMMAND_RPC_GET_TRANSACTIONS::request req = AUTO_VAL_INIT(req);
8927
- COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res);
8928
-
8929
- MDEBUG("Finding and saving rings...");
8930
-
8931
- // get payments we made
8932
- std::vector<crypto::hash> txs_hashes;
8933
- std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> payments;
8934
- get_payments_out(payments, 0, std::numeric_limits<uint64_t>::max(), boost::none, std::set<uint32_t>());
8935
- for (const std::pair<crypto::hash,wallet2::confirmed_transfer_details> &entry: payments)
8936
- {
8937
- const crypto::hash &txid = entry.first;
8938
- txs_hashes.push_back(txid);
8939
- }
8940
-
8941
- MDEBUG("Found " << std::to_string(txs_hashes.size()) << " transactions");
8942
-
8943
- // get those transactions from the daemon
8944
- auto it = txs_hashes.begin();
8945
- static const size_t SLICE_SIZE = 200;
8946
- for (size_t slice = 0; slice < txs_hashes.size(); slice += SLICE_SIZE)
8912
+ if (force)
8947
8913
{
8948
- req.decode_as_json = false;
8949
- req.prune = true;
8950
- req.txs_hashes.clear();
8951
- size_t ntxes = slice + SLICE_SIZE > txs_hashes.size() ? txs_hashes.size() - slice : SLICE_SIZE;
8952
- for (size_t s = slice; s < slice + ntxes; ++s)
8953
- req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txs_hashes[s]));
8954
-
8955
- {
8956
- const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex};
8957
- uint64_t pre_call_credits = m_rpc_payment_state.credits;
8958
- req.client = get_client_signature();
8959
- bool r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout);
8960
- THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, res, "/gettransactions");
8961
- THROW_WALLET_EXCEPTION_IF(res.txs.size() != req.txs_hashes.size(), error::wallet_internal_error,
8962
- "daemon returned wrong response for gettransactions, wrong txs count = " +
8963
- std::to_string(res.txs.size()) + ", expected " + std::to_string(req.txs_hashes.size()));
8964
- check_rpc_cost("/gettransactions", res.credits, pre_call_credits, res.txs.size() * COST_PER_TX);
8965
- }
8966
-
8967
- MDEBUG("Scanning " << res.txs.size() << " transactions");
8968
- THROW_WALLET_EXCEPTION_IF(slice + res.txs.size() > txs_hashes.size(), error::wallet_internal_error, "Unexpected tx array size");
8969
- for (size_t i = 0; i < res.txs.size(); ++i, ++it)
8970
- {
8971
- const auto &tx_info = res.txs[i];
8972
- cryptonote::transaction tx;
8973
- crypto::hash tx_hash;
8974
- THROW_WALLET_EXCEPTION_IF(!get_pruned_tx(tx_info, tx, tx_hash), error::wallet_internal_error,
8975
- "Failed to get transaction from daemon");
8976
- THROW_WALLET_EXCEPTION_IF(!(tx_hash == *it), error::wallet_internal_error, "Wrong txid received");
8977
- THROW_WALLET_EXCEPTION_IF(!add_rings(get_ringdb_key(), tx), error::wallet_internal_error, "Failed to save ring");
8978
- }
8914
+ MWARNING("wallet2::find_and_save_rings() is deprecated");
8915
+ return false;
8979
8916
}
8980
-
8981
- MINFO("Found and saved rings for " << txs_hashes.size() << " transactions");
8982
8917
m_ring_history_saved = true;
8983
8918
return true;
8984
8919
}
0 commit comments