summaryrefslogtreecommitdiff
path: root/patches
diff options
context:
space:
mode:
authorcyan <cyjan@mrcyjanek.net>2025-02-18 15:53:16 +0100
committerGitHub <noreply@github.com>2025-02-18 15:53:16 +0100
commit65608c09e9093f1cd42c6afd8e9131016c82574b (patch)
tree8898b2552fb7cfbc1ebae9870dfe68952f9c7a58 /patches
parent79f07dd4f95af4d513b9bf4330ef846258f36e68 (diff)
relax mutex in invoke call (#120)
Diffstat (limited to 'patches')
-rw-r--r--patches/zano/0010-relax-mutex-in-invoke-call.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/patches/zano/0010-relax-mutex-in-invoke-call.patch b/patches/zano/0010-relax-mutex-in-invoke-call.patch
new file mode 100644
index 0000000..e3e29a7
--- /dev/null
+++ b/patches/zano/0010-relax-mutex-in-invoke-call.patch
@@ -0,0 +1,88 @@
+From 2421d1fb4b4c50c1372361b1688f7d9fff9ef716 Mon Sep 17 00:00:00 2001
+From: Czarek Nakamoto <cyjan@mrcyjanek.net>
+Date: Tue, 18 Feb 2025 14:27:36 +0100
+Subject: [PATCH] relax mutex in invoke call
+
+---
+ src/common/error_codes.h | 1 +
+ src/wallet/wallets_manager.cpp | 37 ++++++++++++++++++++++++++++++----
+ 2 files changed, 34 insertions(+), 4 deletions(-)
+
+diff --git a/src/common/error_codes.h b/src/common/error_codes.h
+index 1e3dc2efc..4723afe40 100644
+--- a/src/common/error_codes.h
++++ b/src/common/error_codes.h
+@@ -45,3 +45,4 @@
+ #define API_RETURN_CODE_HTLC_ORIGIN_HASH_MISSMATCHED "HTLC_ORIGIN_HASH_MISSMATCHED"
+ #define API_RETURN_CODE_WRAP "WRAP"
+ #define API_RETURN_CODE_MISSING_ZC_INPUTS "MISSING_ZC_INPUTS"
++#define API_RETURN_CODE_BAD_JSON "BAD_JSON"
+\ No newline at end of file
+diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp
+index 7155771d2..3da57dc7a 100644
+--- a/src/wallet/wallets_manager.cpp
++++ b/src/wallet/wallets_manager.cpp
+@@ -1675,10 +1675,27 @@ std::string wallets_manager::get_wallet_status(uint64_t wallet_id)
+ return epee::serialization::store_t_to_json(wsi);
+ }
+
++struct json_just_method
++{
++ std::string method;
++ BEGIN_KV_SERIALIZE_MAP()
++ KV_SERIALIZE(method)
++ END_KV_SERIALIZE_MAP()
++};
++
+ std::string wallets_manager::invoke(uint64_t wallet_id, std::string params)
+ {
+ GET_WALLET_OPT_BY_ID(wallet_id, wo);
+
++ json_just_method req = {};
++ if (!epee::serialization::load_t_from_json(req, params))
++ {
++ epee::json_rpc::response<epee::json_rpc::dummy_result, epee::json_rpc::error> error_response = AUTO_VAL_INIT(error_response);
++ error_response.error.code = -1;
++ error_response.error.message = API_RETURN_CODE_BAD_JSON;
++ return epee::serialization::store_t_to_json(error_response);
++ }
++
+ CRITICAL_REGION_LOCAL1(wo.long_refresh_in_progress_lock);
+ if (wo.long_refresh_in_progress)
+ {
+@@ -1688,16 +1705,28 @@ std::string wallets_manager::invoke(uint64_t wallet_id, std::string params)
+ return epee::serialization::store_t_to_json(error_response);
+ }
+
+-
+- auto locker_object = wo.w.lock();
+-
+ epee::net_utils::http::http_request_info query_info = AUTO_VAL_INIT(query_info);
+ epee::net_utils::http::http_response_info response_info = AUTO_VAL_INIT(response_info);
+ epee::net_utils::connection_context_base stub_conn_context = AUTO_VAL_INIT(stub_conn_context);
+ bool call_found = false;
+ query_info.m_URI = "/json_rpc";
+ query_info.m_body = params;
+- wo.rpc_wrapper->handle_http_request_map(query_info, response_info, stub_conn_context, call_found);
++
++ if (req.method != "assets_whitelist_get" &&
++ req.method != "decrypt_data" &&
++ req.method != "encrypt_data" &&
++ req.method != "get_restore_info" &&
++ req.method != "get_seed_phrase_info" &&
++ req.method != "get_wallet_info" &&
++ req.method != "getaddress" &&
++ req.method != "getbalance" &&
++ req.method != "sign_message") {
++ auto locker_object = wo.w.lock();
++ wo.rpc_wrapper->handle_http_request_map(query_info, response_info, stub_conn_context, call_found);
++ } else {
++ wo.rpc_wrapper->handle_http_request_map(query_info, response_info, stub_conn_context, call_found);
++ }
++
+ return response_info.m_body;
+ }
+
+--
+2.48.1
+