1
0
Fork 0
forked from lthn/blockchain

fixed native library for auto-start of sync process in wallet thread

This commit is contained in:
cryptozoidberg 2020-02-13 01:44:30 +01:00
parent 34b8233087
commit c4a423f6f5
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
3 changed files with 34 additions and 9 deletions

View file

@ -28,7 +28,7 @@ namespace plain_wallet
std::string get_bundle_root_dir()
{
#ifdef WIN32
return "undefined";
return "";
#endif // WIN32
char buffer[1000] = {0};
@ -38,7 +38,10 @@ namespace plain_wallet
std::string get_wallets_folder()
{
std::string path = get_bundle_root_dir() + "/" + HOME_FOLDER + "/" + WALLETS_FOLDER_NAME;
#ifdef WIN32
return "";
#endif // WIN32
std::string path = get_bundle_root_dir() + "/" + HOME_FOLDER + "/" + WALLETS_FOLDER_NAME + "/";
return path;
}
@ -115,7 +118,7 @@ namespace plain_wallet
std::string open(const std::string& path, const std::string& password)
{
std::string full_path = get_wallets_folder() + "/" + path;
std::string full_path = get_wallets_folder() + path;
epee::json_rpc::response<view::open_wallet_response, epee::json_rpc::dummy_error> ok_response = AUTO_VAL_INIT(ok_response);
std::string rsp = gwm.open_wallet(epee::string_encoding::convert_to_unicode(full_path), password, 20, ok_response.result);
if (rsp == API_RETURN_CODE_OK || rsp == API_RETURN_CODE_FILE_RESTORED)
@ -124,6 +127,8 @@ namespace plain_wallet
{
ok_response.result.recovered = true;
}
gwm.run_wallet(ok_response.result.wallet_id);
return epee::serialization::store_t_to_json(ok_response);
}
error_response err_result = AUTO_VAL_INIT(err_result);
@ -132,7 +137,7 @@ namespace plain_wallet
}
std::string restore(const std::string& seed, const std::string& path, const std::string& password)
{
std::string full_path = get_wallets_folder() + "/" + path;
std::string full_path = get_wallets_folder() + path;
epee::json_rpc::response<view::open_wallet_response, epee::json_rpc::dummy_error> ok_response = AUTO_VAL_INIT(ok_response);
std::string rsp = gwm.restore_wallet(epee::string_encoding::convert_to_unicode(full_path), password, seed, ok_response.result);
if (rsp == API_RETURN_CODE_OK || rsp == API_RETURN_CODE_FILE_RESTORED)
@ -150,7 +155,7 @@ namespace plain_wallet
std::string generate(const std::string& path, const std::string& password)
{
std::string full_path = get_wallets_folder() + "/" + path;
std::string full_path = get_wallets_folder() + path;
epee::json_rpc::response<view::open_wallet_response, epee::json_rpc::dummy_error> ok_response = AUTO_VAL_INIT(ok_response);
std::string rsp = gwm.generate_wallet(epee::string_encoding::convert_to_unicode(full_path), password, ok_response.result);
if (rsp == API_RETURN_CODE_OK || rsp == API_RETURN_CODE_FILE_RESTORED)

View file

@ -1616,7 +1616,7 @@ 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)
if(*plast_daemon_height - last_wallet_synch_height > 10)
{
CRITICAL_REGION_LOCAL(long_refresh_in_progress_lock);
long_refresh_in_progress = true;

View file

@ -19,7 +19,28 @@ using namespace epee;
void run_plain_wallet_api_test()
{
LOG_PRINT_L0("Creating instance...");
std::string s = plain_wallet::init("127.0.0.1", "11211");
std::string s = plain_wallet::init("195.201.107.230", "11211");
LOG_PRINT_L0("Generating wallet...");
std::string rsp = plain_wallet::open(std::string("E:\\tmp\\zano_testwallet_745ss65030.zan"), "");
LOG_PRINT_L0("RESPONSE:" << ENDL << rsp);
epee::json_rpc::response<view::open_wallet_response, epee::json_rpc::dummy_error> ok_response = AUTO_VAL_INIT(ok_response);
epee::serialization::load_t_from_json(ok_response, rsp);
while (true)
{
std::string prog = plain_wallet::get_wallet_status(ok_response.result.wallet_id);
LOG_PRINT_L0("Progress: " << ENDL << prog);
// view::sta ssr = AUTO_VAL_INIT(ssr);
// epee::serialization::load_t_from_json(ssr, prog);
// LOG_PRINT_L0("Progress: " << ssr.progress << "Finished: " << ssr.finished);
// if (ssr.finished)
// break;
epee::misc_utils::sleep_no_w(1000);
}
}
// LOG_PRINT_L0("Creating instance..." << std::hex << hw);
//
// LOG_PRINT_L0("Generating wallet...");
@ -157,5 +178,4 @@ void run_plain_wallet_api_test()
// LOG_PRINT_L0("Balance request returned: code [" << gbres.error.code << "], str_response: "
// << ENDL << res);
// }
// }
}
// }}