find_tx_in_mempool method completed

pull/88/head
moneroexamples 6 years ago
parent f6062c6ef4
commit a3e5b40c29

@ -3,7 +3,7 @@ var config = {
mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.xmrchain.com/",
stagenetExplorerUrl: "http://162.210.173.150:8083/",
nettype: 2, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
nettype: 1, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
coinUnitPlaces: 12,
txMinConfirms: 10, // corresponds to CRYPTONOTE_DEFAULT_TX_SPENDABLE_AGE in Monero
txCoinbaseMinConfirms: 60, // corresponds to CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW in Monero

@ -244,7 +244,7 @@ CurrentBlockchainStatus::tx_exist(const string& tx_hash_str, uint64_t& tx_index)
return tx_exist(tx_hash, tx_index);
}
false;
return false;
}
bool
@ -879,6 +879,20 @@ CurrentBlockchainStatus::find_tx_in_mempool(
transaction& tx)
{
std::lock_guard<std::mutex> lck (searching_threads_map_mtx);
for (auto const& mtx: mempool_txs)
{
const transaction &m_tx = mtx.second;
if (get_transaction_hash(m_tx) == tx_hash)
{
tx = m_tx;
return true;
}
}
return false;
}
bool

@ -33,6 +33,12 @@ static mutex getting_mempool_txs;
*/
struct CurrentBlockchainStatus
{
// vector of mempool transactions that all threads
// can refer to
// <recieved_time, transaction>
using mempool_txs_t = vector<pair<uint64_t, transaction>>;
static string blockchain_path;
static atomic<uint64_t> current_height;
@ -65,7 +71,7 @@ struct CurrentBlockchainStatus
// vector of mempool transactions that all threads
// can refer to
// <recieved_time, transaction>
static vector<pair<uint64_t, transaction>> mempool_txs;
static mempool_txs_t mempool_txs;
// map that will keep track of search threads. In the
// map, key is address to which a running thread belongs to.

@ -109,10 +109,10 @@ YourMoneroRequests::login(const shared_ptr<Session> session, const Bytes & body)
// make it 1 block lower than current, just in case.
// this variable will be our using to initialize
// `scanned_block_height` in mysql Accounts table.
if (acc_id = xmr_accounts->insert(xmr_address,
if ((acc_id = xmr_accounts->insert(xmr_address,
make_hash(view_key),
blk_timestamp_mysql_format,
current_blockchain_height) == 0)
current_blockchain_height)) == 0)
{
// if creating account failed
j_response = json {{"status", "error"},

Loading…
Cancel
Save