1
0
Fork 0
forked from lthn/blockchain

quick fix for UI being to early on rpc calls

This commit is contained in:
cryptozoidberg 2024-02-23 22:31:15 +04:00
parent 91ec911213
commit 13e21c0e7e
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
3 changed files with 14 additions and 2 deletions

View file

@ -272,13 +272,23 @@ QString MainWindow::request_dummy()
QString MainWindow::call_rpc(const QString& params)
{
TRY_ENTRY();
if (!m_backend.is_core_initialized())
{
epee::json_rpc::error_response rsp;
rsp.jsonrpc = "2.0";
rsp.error.code = -1;
rsp.error.message = API_RETURN_CODE_CORE_BUSY;
return QString::fromStdString(epee::serialization::store_t_to_json(static_cast<epee::json_rpc::error_response&>(rsp)));
}
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);
currency::core_rpc_server::connection_context dummy_context = AUTO_VAL_INIT(dummy_context);
query_info.m_URI = "/json_rpc";
query_info.m_body = params.toStdString();
m_backend.get_rpc_server().handle_http_request(query_info, response_info, dummy_context);
if (response_info.m_response_code != 200)
{

View file

@ -506,7 +506,6 @@ bool wallets_manager::init_local_daemon()
CHECK_AND_ASSERT_AND_SET_GUI(res, "Failed to initialize core");
LOG_PRINT_L0("Core initialized OK");
//check if offers module synchronized with blockchaine storage
auto& bcs = m_ccore.get_blockchain_storage();
if (!m_offers_service.is_disabled() && bcs.get_current_blockchain_size() > 1 && bcs.get_top_block_id() != m_offers_service.get_last_seen_block_id())
@ -562,6 +561,7 @@ bool wallets_manager::init_local_daemon()
CHECK_AND_ASSERT_AND_SET_GUI(res, "Failed to initialize core rpc server.");
LOG_PRINT_L0("Core rpc server started ok");
m_core_initialized = true;
LOG_PRINT_L0("Starting p2p net loop...");
//dsi.text_state = "Starting network loop";
m_pview->update_daemon_status(dsi);

View file

@ -173,6 +173,7 @@ public:
bool set_use_tor(bool use_tor);
std::string add_custom_asset_id(uint64_t wallet_id, const crypto::public_key& asset_id, currency::asset_descriptor_base& asset_descriptor);
std::string delete_custom_asset_id(uint64_t wallet_id, const crypto::public_key& asset_id);
bool is_core_initialized() { return m_core_initialized;}
private:
void main_worker(const po::variables_map& vm);
@ -244,6 +245,7 @@ private:
// std::atomic<uint64_t> m_last_wallet_synch_height;
std::atomic<uint64_t> m_wallet_id_counter;
std::atomic<bool> m_dont_save_wallet_at_stop;
std::atomic<bool> m_core_initialized = false;
std::string m_data_dir;
view::gui_options m_ui_opt;