Skip to content

Commit

Permalink
Add more detailes to logs
Browse files Browse the repository at this point in the history
  • Loading branch information
moneroexamples committed Jun 11, 2019
1 parent ada4b03 commit bab01c8
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
3 changes: 2 additions & 1 deletion html/js/config.js
@@ -1,5 +1,6 @@
var config = {
apiUrl: "http://127.0.0.1:1984/",
apiUrl: "http://0.0.0.0:1984/",
//apiUrl: "http://127.0.0.1:1984/",
mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.xmrchain.com/",
stagenetExplorerUrl: "http://139.162.60.17:8082/",
Expand Down
5 changes: 4 additions & 1 deletion src/CurrentBlockchainStatus.cpp
Expand Up @@ -822,7 +822,10 @@ CurrentBlockchainStatus::start_tx_search_thread(
}
catch (const std::exception& e)
{
OMERROR << "Faild created a search thread: " << e.what();
OMERROR << acc.address.substr(0,6)
<< ": Faild created a search thread: "
<< e.what();

return false;
}

Expand Down
41 changes: 29 additions & 12 deletions src/OpenMoneroRequests.cpp
Expand Up @@ -135,15 +135,19 @@ OpenMoneroRequests::login(const shared_ptr<Session> session, const Bytes & body)
if (login_and_start_search_thread(xmr_address, view_key, *acc, j_response))
{
// if successfuly logged in and created search thread
j_response["status"] = "success";
j_response["status"] = "success";

// we overwrite what ever was sent in login_and_start_search_thread
// we overwrite what ever was sent in login_and_start_search_thread
// for the j_response["new_address"].
j_response["new_address"] = new_account_created;
j_response["new_address"] = new_account_created;
}
else
{
// some error with loggin in or search thread start
OMERROR << xmr_address.substr(0,6) << ": "
<< "login_and_start_search_thread failed. "
<< j_response.dump();

session_close(session, j_response);
return;

Expand Down Expand Up @@ -206,12 +210,7 @@ OpenMoneroRequests::ping(const shared_ptr<Session> session, const Bytes & body)

j_response["status"] = "success";

string response_body = j_response.dump();

auto response_headers = make_headers({{ "Content-Length",
to_string(response_body.size())}});

session->close(OK, response_body, response_headers);
session_close(session, j_response);
}

void
Expand Down Expand Up @@ -2145,8 +2144,13 @@ OpenMoneroRequests::create_account(
if (xmr_accounts->select(xmr_address, *acc))
{
// if acc already exist, just return
// existing one
return acc;
// existing oneo

OMINFO << xmr_address.substr(0,6)
<< ": account already exists. "
<< "Return existing account";

return *acc;
}

uint64_t current_blockchain_height = get_current_blockchain_height();
Expand Down Expand Up @@ -2215,7 +2219,9 @@ OpenMoneroRequests::create_account(
if ((acc_id = xmr_accounts->insert(*acc)) == 0)
{
// if creating account failed
OMERROR << xmr_address.substr(0,6) + ": account creation failed";
OMERROR << xmr_address.substr(0,6)
<< ": account creation failed: "
<< (*acc) ;

return {};
}
Expand Down Expand Up @@ -2244,16 +2250,27 @@ OpenMoneroRequests::select_account(
": address does not exists";

if (!create_if_notfound)
{
OMINFO << "create_if_notfound is false";
return {};
}

// for this address
if (!(acc = create_account(xmr_address, view_key)))
{
OMERROR << xmr_address.substr(0,6)
<< ": create_account failed";
return {};
}

// once account has been created
// make and start a search thread for it
if (!make_search_thread(*acc))
{
OMERROR << xmr_address.substr(0,6)
<< ": make_search_thread failed";
return {};
}
}

// also need to check if view key matches
Expand Down
14 changes: 11 additions & 3 deletions src/TxSearch.cpp
Expand Up @@ -391,7 +391,11 @@ for (auto const& tx_tuple: txs_data)

if (no_rows_inserted == 0)
{
throw TxSearchException("no_rows_inserted is zero!");
OMERROR << address_prefix
<< ": insert outputs_found: no_rows_inserted is zero!"
<< outputs_found;

throw TxSearchException("insert output_found: no_rows_inserted is zero!");
}

} // if (!found_mine_outputs.empty())
Expand Down Expand Up @@ -572,11 +576,15 @@ for (auto const& tx_tuple: txs_data)

uint64_t no_rows_inserted
= xmr_accounts->insert(inputs_found);

if (no_rows_inserted == 0)
{
OMERROR << address_prefix
<< ": insert inputs_found: no_rows_inserted is zero!"
<< inputs_found;

throw TxSearchException(
"no_rows_inserted is zero!");
"insert inputs_found: no_rows_inserted is zero!");
}

} // if (!inputs_found.empty())
Expand Down

0 comments on commit bab01c8

Please sign in to comment.