forked from lthn/blockchain
introduced new long-call mode for wallets_manager
This commit is contained in:
parent
c6dd8b1153
commit
1c35304d0b
5 changed files with 39 additions and 7 deletions
|
|
@ -216,9 +216,12 @@ namespace plain_wallet
|
|||
// GET_INSTANCE(pimpl, h);
|
||||
// return pimpl->sync();
|
||||
// }
|
||||
std::string get_wallet_status(hwallet h)
|
||||
{
|
||||
|
||||
}
|
||||
std::string invoke(hwallet h, const std::string& params)
|
||||
{
|
||||
GET_INSTANCE(pimpl, h);
|
||||
return pimpl->invoke(params);
|
||||
return gwm.invoke(h, params);
|
||||
}
|
||||
}
|
||||
|
|
@ -15,15 +15,16 @@ namespace plain_wallet
|
|||
std::string init(const std::string& ip, const std::string& port);
|
||||
std::string get_version();
|
||||
std::string get_wallet_files();
|
||||
std::string print_money(int64_t);
|
||||
//std::string print_money(int64_t);
|
||||
|
||||
std::string open(hwallet h, const std::string& path, const std::string& password);
|
||||
std::string restore(hwallet h, const std::string& seed, const std::string& path, const std::string& password);
|
||||
std::string generate(hwallet h, const std::string& path, const std::string& password);
|
||||
|
||||
std::string start_sync_thread(hwallet h);
|
||||
std::string get_sync_status(hwallet h);
|
||||
std::string cancel_sync_thread(hwallet h);
|
||||
std::string sync(hwallet h);
|
||||
// std::string start_sync_thread(hwallet h);
|
||||
// std::string get_sync_status(hwallet h);
|
||||
// std::string cancel_sync_thread(hwallet h);
|
||||
// std::string sync(hwallet h);
|
||||
std::string get_wallet_status(hwallet h);
|
||||
std::string invoke(hwallet h, const std::string& params);
|
||||
}
|
||||
|
|
@ -747,6 +747,7 @@ public:
|
|||
#define API_RETURN_CODE_FALSE "FALSE"
|
||||
#define API_RETURN_CODE_CORE_BUSY "CORE_BUSY"
|
||||
#define API_RETURN_CODE_OVERFLOW "OVERFLOW"
|
||||
#define API_RETURN_CODE_BUSY "BUSY"
|
||||
|
||||
#define API_MAX_ALIASES_COUNT 10000
|
||||
|
||||
|
|
|
|||
|
|
@ -1131,9 +1131,24 @@ std::string wallets_manager::transfer(size_t wallet_id, const view::transfer_par
|
|||
return API_RETURN_CODE_OK;
|
||||
}
|
||||
|
||||
std::string wallets_manager::get_wallet_status(uint64_t wallet_id)
|
||||
{
|
||||
|
||||
}
|
||||
std::string wallets_manager::invoke(uint64_t wallet_id, std::string params)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, wo);
|
||||
|
||||
CRITICAL_REGION_LOCAL(wo.long_refresh_in_progress_lock);
|
||||
if (wo.long_refresh_in_progress)
|
||||
{
|
||||
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_BUSY;
|
||||
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);
|
||||
|
|
@ -1542,6 +1557,13 @@ void wallets_manager::wallet_vs_options::worker_func()
|
|||
if (last_wallet_synch_height && *plast_daemon_height - last_wallet_synch_height < 3)
|
||||
show_progress = false;
|
||||
|
||||
if(last_wallet_synch_height && *plast_daemon_height - last_wallet_synch_height > 10)
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(long_refresh_in_progress_lock);
|
||||
long_refresh_in_progress = true;
|
||||
}
|
||||
|
||||
|
||||
if (show_progress)
|
||||
{
|
||||
wallet_state = wsi.wallet_state = view::wallet_status_info::wallet_state_synchronizing;
|
||||
|
|
@ -1549,6 +1571,7 @@ void wallets_manager::wallet_vs_options::worker_func()
|
|||
pview->update_wallet_status(wsi);
|
||||
}
|
||||
w->get()->refresh(stop_for_refresh);
|
||||
long_refresh_in_progress = false;
|
||||
w->get()->resend_unconfirmed();
|
||||
{
|
||||
auto w_ptr = *w; // get locked exclusive access to the wallet first (it's more likely that wallet is locked for a long time than 'offers')
|
||||
|
|
|
|||
|
|
@ -70,6 +70,10 @@ public:
|
|||
std::atomic<bool>* plast_daemon_is_disconnected;
|
||||
std::atomic<bool> has_related_alias_in_unconfirmed;
|
||||
std::atomic<bool> need_to_update_wallet_info;
|
||||
|
||||
std::atomic<bool> long_refresh_in_progress;
|
||||
epee::critical_section long_refresh_in_progress_lock; //secure wallet state and prevent from long wait while long refresh is in work
|
||||
|
||||
view::i_view* pview;
|
||||
uint64_t wallet_id;
|
||||
epee::locked_object<std::list<bc_services::offer_details_ex>> offers;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue