diff --git a/src/wallet/plain_wallet_api.cpp b/src/wallet/plain_wallet_api.cpp index 114f9604..73200606 100644 --- a/src/wallet/plain_wallet_api.cpp +++ b/src/wallet/plain_wallet_api.cpp @@ -10,8 +10,6 @@ #include "currency_core/currency_format_utils.h" #include "wallets_manager.h" -std::atomic initialized(false); - #define ANDROID_PACKAGE_NAME "com.zano_mobile" #ifdef IOS_BUILD #define HOME_FOLDER "Documents" @@ -27,6 +25,11 @@ std::atomic initialized(false); //TODO: global object, subject to refactoring wallets_manager gwm; +std::atomic initialized(false); + +std::atomic gjobs_counter(1); +std::map gjobs; +epee::critical_section gjobs_lock; namespace plain_wallet { @@ -198,4 +201,43 @@ namespace plain_wallet { return gwm.invoke(h, params); } + + void put_result(uint64_t job_is, const std::string& res) + { + + } + + uint64_t async_call(const std::string& method_name, const std::string& params) + { + std::function async_callback; + + uint64_t job_id = gjobs_counter++; + std::string local_copy_params = params; + if (method_name == "close_wallet") + { + uint64_t wal_id = 0; + epee::string_tools:get_xnum_from_hex_string(params, wal_id); + if() + async_callback = []() + {return + + + }; + } + else if (method_name == "open") + { + view::open_wallet_request + + } + + std::thread([job_id, local_copy_params]() { + //some heavy call here + }); + return job_id; + } + std::string try_pull_result(uint64_t) + { + return ""; + } + } \ No newline at end of file diff --git a/src/wallet/plain_wallet_api.h b/src/wallet/plain_wallet_api.h index 9c2e8fb0..46749120 100644 --- a/src/wallet/plain_wallet_api.h +++ b/src/wallet/plain_wallet_api.h @@ -21,4 +21,8 @@ namespace plain_wallet std::string get_wallet_status(hwallet h); std::string close_wallet(hwallet h); std::string invoke(hwallet h, const std::string& params); + + //async api + uint64_t async_call(const std::string& method_name, const std::string& params); + std::string try_pull_result(uint64_t); } \ No newline at end of file