diff options
| author | jeffro256 <jeffro256@tutanota.com> | 2025-07-29 11:58:05 -0500 |
|---|---|---|
| committer | jeffro256 <jeffro256@tutanota.com> | 2025-07-29 12:32:20 -0500 |
| commit | 8f98dac4f02e1c7f431c3917f95cb9a235e668b9 (patch) | |
| tree | 8700c9d7d9eb3bcf3f365f6d5963c30c4b222e4d /src/wallet/wallet2.cpp | |
| parent | ec870e50706a29768a65f597155ed5c7ad7e6326 (diff) | |
| download | monzero-core-8f98dac4f02e1c7f431c3917f95cb9a235e668b9.tar.gz monzero-core-8f98dac4f02e1c7f431c3917f95cb9a235e668b9.tar.xz monzero-core-8f98dac4f02e1c7f431c3917f95cb9a235e668b9.zip | |
wallet: deprecate wallet2::find_and_save_rings()
Rings for outgoing transactions are stored within the scanning code since the last hardfork,
so this code is largely unneccessary now.
Co-authored-by: j-berman <justinberman@protonmail.com>
Diffstat (limited to 'src/wallet/wallet2.cpp')
| -rw-r--r-- | src/wallet/wallet2.cpp | 73 |
1 files changed, 4 insertions, 69 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index e9f59cd8c..3cb583afe 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -1250,7 +1250,7 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std m_original_keys_available(false), m_message_store(http_client_factory->create()), m_key_device_type(hw::device::device_type::SOFTWARE), - m_ring_history_saved(false), + m_ring_history_saved(true), m_ringdb(), m_last_block_reward(0), m_unattended(unattended), @@ -6522,15 +6522,6 @@ void wallet2::load(const std::string& wallet_, const epee::wipeable_string& pass try { - find_and_save_rings(false); - } - catch (const std::exception &e) - { - MERROR("Failed to save rings, will try again next time"); - } - - try - { if (use_fs) m_message_store.read_from_file(get_multisig_wallet_state(), m_mms_file, m_load_deprecated_formats); } @@ -8918,67 +8909,11 @@ bool wallet2::unset_ring(const crypto::hash &txid) bool wallet2::find_and_save_rings(bool force) { - if (!force && m_ring_history_saved) - return true; - if (!m_ringdb) - return false; - - COMMAND_RPC_GET_TRANSACTIONS::request req = AUTO_VAL_INIT(req); - COMMAND_RPC_GET_TRANSACTIONS::response res = AUTO_VAL_INIT(res); - - MDEBUG("Finding and saving rings..."); - - // get payments we made - std::vector<crypto::hash> txs_hashes; - std::list<std::pair<crypto::hash,wallet2::confirmed_transfer_details>> payments; - get_payments_out(payments, 0, std::numeric_limits<uint64_t>::max(), boost::none, std::set<uint32_t>()); - for (const std::pair<crypto::hash,wallet2::confirmed_transfer_details> &entry: payments) - { - const crypto::hash &txid = entry.first; - txs_hashes.push_back(txid); - } - - MDEBUG("Found " << std::to_string(txs_hashes.size()) << " transactions"); - - // get those transactions from the daemon - auto it = txs_hashes.begin(); - static const size_t SLICE_SIZE = 200; - for (size_t slice = 0; slice < txs_hashes.size(); slice += SLICE_SIZE) + if (force) { - req.decode_as_json = false; - req.prune = true; - req.txs_hashes.clear(); - size_t ntxes = slice + SLICE_SIZE > txs_hashes.size() ? txs_hashes.size() - slice : SLICE_SIZE; - for (size_t s = slice; s < slice + ntxes; ++s) - req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txs_hashes[s])); - - { - const boost::lock_guard<boost::recursive_mutex> lock{m_daemon_rpc_mutex}; - uint64_t pre_call_credits = m_rpc_payment_state.credits; - req.client = get_client_signature(); - bool r = epee::net_utils::invoke_http_json("/gettransactions", req, res, *m_http_client, rpc_timeout); - THROW_ON_RPC_RESPONSE_ERROR_GENERIC(r, {}, res, "/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())); - check_rpc_cost("/gettransactions", res.credits, pre_call_credits, res.txs.size() * COST_PER_TX); - } - - MDEBUG("Scanning " << res.txs.size() << " transactions"); - THROW_WALLET_EXCEPTION_IF(slice + res.txs.size() > txs_hashes.size(), error::wallet_internal_error, "Unexpected tx array size"); - for (size_t i = 0; i < res.txs.size(); ++i, ++it) - { - const auto &tx_info = res.txs[i]; - cryptonote::transaction tx; - crypto::hash tx_hash; - THROW_WALLET_EXCEPTION_IF(!get_pruned_tx(tx_info, tx, tx_hash), error::wallet_internal_error, - "Failed to get transaction from daemon"); - THROW_WALLET_EXCEPTION_IF(!(tx_hash == *it), error::wallet_internal_error, "Wrong txid received"); - THROW_WALLET_EXCEPTION_IF(!add_rings(get_ringdb_key(), tx), error::wallet_internal_error, "Failed to save ring"); - } + MWARNING("wallet2::find_and_save_rings() is deprecated"); + return false; } - - MINFO("Found and saved rings for " << txs_hashes.size() << " transactions"); m_ring_history_saved = true; return true; } |
