From 5a2489c05eb64a09457d1d628e989d01991f3985 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Fri, 2 Jun 2017 11:21:47 +0800 Subject: [PATCH] rpccalls::get_mempool refactored --- src/rpccalls.cpp | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/rpccalls.cpp b/src/rpccalls.cpp index ddce8ef..b366bb3 100644 --- a/src/rpccalls.cpp +++ b/src/rpccalls.cpp @@ -76,26 +76,29 @@ rpccalls::get_mempool(vector& mempool_txs) COMMAND_RPC_GET_TRANSACTION_POOL::request req; COMMAND_RPC_GET_TRANSACTION_POOL::response res; - std::lock_guard guard(m_daemon_rpc_mutex); + bool r; - if (!connect_to_monero_deamon()) { - cerr << "get_mempool: not connected to deamon" << endl; - return false; - } + std::lock_guard guard(m_daemon_rpc_mutex); - bool r = epee::net_utils::invoke_http_json( - "/get_transaction_pool", - req, res, m_http_client, timeout_time_ms); + if (!connect_to_monero_deamon()) + { + cerr << "get_mempool: not connected to deamon" << endl; + return false; + } - if (!r) + r = epee::net_utils::invoke_http_json( + "/get_transaction_pool", + req, res, m_http_client, timeout_time_ms); + } + + if (!r || res.status != CORE_RPC_STATUS_OK) { cerr << "Error connecting to Monero deamon at " << deamon_url << endl; return false; } - mempool_txs = res.transactions; // mempool txs are not sorted base on their arival time, @@ -107,7 +110,6 @@ rpccalls::get_mempool(vector& mempool_txs) return t1.receive_time > t2.receive_time; }); - return true; }