diff options
author | luigi1111 <luigi1111w@gmail.com> | 2022-07-05 23:58:46 -0500 |
---|---|---|
committer | luigi1111 <luigi1111w@gmail.com> | 2022-07-05 23:58:46 -0500 |
commit | 45a44aa45f071909063e8b449526fc9ba2b8391b (patch) | |
tree | d15b5b31d77c6184d9ec025d8801cd7fc0c79d02 | |
parent | Merge pull request #8371 (diff) | |
parent | Chunk /gettransactions to avoid hitting restricted RPC limit (diff) | |
download | monero-45a44aa45f071909063e8b449526fc9ba2b8391b.tar.xz |
Merge pull request #8388
04c0da2 Chunk /gettransactions to avoid hitting restricted RPC limit (tobtoht)
-rw-r--r-- | src/wallet/wallet2.cpp | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 37f7e29c5..cb49d473e 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3160,14 +3160,18 @@ void wallet2::update_pool_state(std::vector<std::tuple<cryptonote::transaction, } } - // get those txes - if (!txids.empty()) + // get_transaction_pool_hashes.bin may return more transactions than we're allowed to request in restricted mode + const size_t SLICE_SIZE = 100; // RESTRICTED_TRANSACTIONS_COUNT as defined in rpc/core_rpc_server.cpp + for (size_t offset = 0; offset < txids.size(); offset += SLICE_SIZE) { cryptonote::COMMAND_RPC_GET_TRANSACTIONS::request req; cryptonote::COMMAND_RPC_GET_TRANSACTIONS::response res; - for (const auto &p: txids) - req.txs_hashes.push_back(epee::string_tools::pod_to_hex(p.first)); - MDEBUG("asking for " << txids.size() << " transactions"); + + const size_t n_txids = std::min<size_t>(SLICE_SIZE, txids.size() - offset); + for (size_t n = offset; n < (offset + n_txids); ++n) { + req.txs_hashes.push_back(epee::string_tools::pod_to_hex(txids.at(n).first)); + } + MDEBUG("asking for " << req.txs_hashes.size() << " transactions"); req.decode_as_json = false; req.prune = true; @@ -3184,7 +3188,7 @@ void wallet2::update_pool_state(std::vector<std::tuple<cryptonote::transaction, MDEBUG("Got " << r << " and " << res.status); if (r && res.status == CORE_RPC_STATUS_OK) { - if (res.txs.size() == txids.size()) + if (res.txs.size() == req.txs_hashes.size()) { for (const auto &tx_entry: res.txs) { @@ -3220,7 +3224,7 @@ void wallet2::update_pool_state(std::vector<std::tuple<cryptonote::transaction, } else { - LOG_PRINT_L0("Expected " << txids.size() << " tx(es), got " << res.txs.size()); + LOG_PRINT_L0("Expected " << n_txids << " out of " << txids.size() << " tx(es), got " << res.txs.size()); } } else |