forked from lthn/blockchain
fixed bugs and code clean up
This commit is contained in:
parent
1c35304d0b
commit
88a657cbb7
5 changed files with 35 additions and 48 deletions
|
|
@ -54,9 +54,16 @@ namespace plain_wallet
|
|||
return path;
|
||||
}
|
||||
|
||||
std::string print_money(int64_t amount)
|
||||
void initialize_logs()
|
||||
{
|
||||
return currency::print_money(amount);
|
||||
std::string log_dir = get_bundle_root_dir();
|
||||
log_dir += "/" HOME_FOLDER;
|
||||
epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
|
||||
epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
|
||||
epee::log_space::log_singletone::add_logger(LOGGER_FILE, "plain_wallet.log", log_dir.c_str());
|
||||
LOG_PRINT_L0("Plain wallet initialized: " << CURRENCY_NAME << " v" << PROJECT_VERSION_LONG << ", log location: " << log_dir + "/plain_wallet.log");
|
||||
|
||||
//glogs_initialized = true;
|
||||
}
|
||||
|
||||
std::string init(const std::string& ip, const std::string& port)
|
||||
|
|
@ -84,17 +91,7 @@ namespace plain_wallet
|
|||
return API_RETURN_CODE_OK;
|
||||
}
|
||||
|
||||
void initialize_logs()
|
||||
{
|
||||
std::string log_dir = get_bundle_root_dir();
|
||||
log_dir += "/" HOME_FOLDER;
|
||||
epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
|
||||
epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
|
||||
epee::log_space::log_singletone::add_logger(LOGGER_FILE, "plain_wallet.log", log_dir.c_str());
|
||||
LOG_PRINT_L0("Plain wallet initialized: " << CURRENCY_NAME << " v" << PROJECT_VERSION_LONG << ", log location: " << log_dir + "/plain_wallet.log");
|
||||
|
||||
//glogs_initialized = true;
|
||||
}
|
||||
|
||||
std::string get_version()
|
||||
{
|
||||
|
|
@ -119,31 +116,6 @@ namespace plain_wallet
|
|||
return epee::serialization::store_t_to_json(sl);
|
||||
}
|
||||
|
||||
hwallet create_instance(const std::string& ip, const std::string& port)
|
||||
{
|
||||
|
||||
// plain_wallet_api_impl* ptr = new plain_wallet_api_impl(ip, port);
|
||||
// hwallet new_h = gcounter++;
|
||||
// CRITICAL_REGION_BEGIN(ginstances_lock);
|
||||
// ginstances[new_h] = ptr;
|
||||
// CRITICAL_REGION_END();
|
||||
// return new_h;
|
||||
}
|
||||
|
||||
void destroy_instance(hwallet h)
|
||||
{
|
||||
// plain_wallet_api_impl* instance_ptr = nullptr;
|
||||
// CRITICAL_REGION_BEGIN(ginstances_lock);
|
||||
// auto it = ginstances.find(h);
|
||||
// if (it == ginstances.end())
|
||||
// {
|
||||
// LOG_ERROR("Internal error: attempt to delete wallet with wrong instance id: " << h);
|
||||
// }
|
||||
// instance_ptr = it->second;
|
||||
// ginstances.erase(it);
|
||||
// CRITICAL_REGION_END();
|
||||
// delete instance_ptr;
|
||||
}
|
||||
std::string open(const std::string& path, const std::string& password)
|
||||
{
|
||||
epee::json_rpc::response<view::open_wallet_response, epee::json_rpc::dummy_error> ok_response = AUTO_VAL_INIT(ok_response);
|
||||
|
|
@ -218,7 +190,7 @@ namespace plain_wallet
|
|||
// }
|
||||
std::string get_wallet_status(hwallet h)
|
||||
{
|
||||
|
||||
return gwm.get_wallet_status(h);
|
||||
}
|
||||
std::string invoke(hwallet h, const std::string& params)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -15,16 +15,11 @@ 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 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 open(const std::string& path, const std::string& password);
|
||||
std::string restore(const std::string& seed, const std::string& path, const std::string& password);
|
||||
std::string generate(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 get_wallet_status(hwallet h);
|
||||
std::string invoke(hwallet h, const std::string& params);
|
||||
}
|
||||
|
|
@ -520,6 +520,19 @@ public:
|
|||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct wallet_sync_status_info
|
||||
{
|
||||
uint64_t wallet_state;
|
||||
bool is_in_long_refresh;
|
||||
uint64_t progress;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_state)
|
||||
KV_SERIALIZE(is_in_long_refresh)
|
||||
KV_SERIALIZE(progress)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct get_restore_info_response
|
||||
{
|
||||
std::string restore_key;
|
||||
|
|
|
|||
|
|
@ -1133,13 +1133,19 @@ std::string wallets_manager::transfer(size_t wallet_id, const view::transfer_par
|
|||
|
||||
std::string wallets_manager::get_wallet_status(uint64_t wallet_id)
|
||||
{
|
||||
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, wo);
|
||||
view::wallet_sync_status_info wsi = AUTO_VAL_INIT(wsi);
|
||||
wsi.is_in_long_refresh = wo.long_refresh_in_progress;
|
||||
wsi.progress = wo.w.unlocked_get().get()->get_sync_progress();
|
||||
wsi.wallet_state = wo.wallet_state;
|
||||
return epee::serialization::store_t_to_json(wsi);
|
||||
}
|
||||
|
||||
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);
|
||||
CRITICAL_REGION_LOCAL1(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);
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ public:
|
|||
std::string generate_wallet(const std::wstring& path, const std::string& password, view::open_wallet_response& owr);
|
||||
std::string restore_wallet(const std::wstring& path, const std::string& password, const std::string& restore_key, view::open_wallet_response& owr);
|
||||
std::string invoke(uint64_t wallet_id, std::string params);
|
||||
std::string get_wallet_status(uint64_t wallet_id);
|
||||
std::string run_wallet(uint64_t wallet_id);
|
||||
std::string get_recent_transfers(size_t wallet_id, uint64_t offset, uint64_t count, view::transfers_array& tr_hist);
|
||||
std::string get_wallet_info(size_t wallet_id, view::wallet_info& wi);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue