Fix for Failed to get tx meta from txpool

https://github.com/moneroexamples/openmonero/issues/169
fix_txpool
moneroexamples 4 years ago
parent a2c1610c60
commit 4e90690146

@ -3,7 +3,7 @@ var config = {
mainnetExplorerUrl: "https://xmrchain.com/",
testnetExplorerUrl: "https://testnet.xmrchain.com/",
stagenetExplorerUrl: "http://139.162.60.17:8082/",
nettype: 0, /* 0 - MAINNET, 1 - TESTNET, 2 - STAGENET */
nettype: 2, /* 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

@ -590,62 +590,51 @@ bool
CurrentBlockchainStatus::read_mempool()
{
// get txs in the mempool
std::vector<tx_info> mempool_tx_info;
vector<spent_key_image_info> key_image_infos;
mempool_txs_t local_mempool_txs;
auto future_result = thread_pool->submit(
[this](auto& mempool_tx_info, auto& key_image_infos)
[this](auto& local_mempool_txs)
-> bool
{
if (!this->mcore->get_mempool_txs(
mempool_tx_info, key_image_infos))
std::vector<transaction> txs;
if (!this->mcore->get_mempool_txs(txs))
{
OMERROR << "Getting mempool failed ";
return false;
}
return true;
}, std::ref(mempool_tx_info),
std::ref(key_image_infos));
if (!future_result.get())
return false;
for (size_t i = 0; i < txs.size(); ++i)
{
// get transaction info of the tx in the mempool
auto const& tx = txs.at(i);
// not using this info at present
(void) key_image_infos;
tx_memory_pool::tx_details txd;
std::lock_guard<std::mutex> lck (getting_mempool_txs);
txpool_tx_meta_t meta;
// clear current mempool txs vector
// repopulate it with each execution of read_mempool()
// not very efficient but good enough for now.
mempool_txs.clear();
if (!this->mcore->get_core().get_txpool_tx_meta(tx.hash, meta))
{
OMERROR << "Failed to find tx in txpool";
return false;
}
// if dont have tx_blob member, construct tx
// from json obtained from the rpc call
local_mempool_txs.emplace_back(meta.receive_time, tx);
for (size_t i = 0; i < mempool_tx_info.size(); ++i)
{
// get transaction info of the tx in the mempool
tx_info const& _tx_info = mempool_tx_info.at(i);
} // for (size_t i = 0; i < mempool_tx_info.size(); ++i)
transaction tx;
crypto::hash tx_hash;
crypto::hash tx_prefix_hash;
return true;
if (!parse_and_validate_tx_from_blob(
_tx_info.tx_blob, tx, tx_hash, tx_prefix_hash))
{
OMERROR << "Cant make tx from _tx_info.tx_blob";
return false;
}
}, std::ref(local_mempool_txs));
(void) tx_hash;
(void) tx_prefix_hash;
if (!future_result.get())
return false;
mempool_txs.emplace_back(_tx_info.receive_time, tx);
std::lock_guard<std::mutex> lck (getting_mempool_txs);
} // for (size_t i = 0; i < mempool_tx_info.size(); ++i)
mempool_txs = std::move(local_mempool_txs);
return true;
}

@ -1 +1 @@
Subproject commit 4a330c66a907df69d6bbd581684d6d05b43aeda5
Subproject commit 6e0c9e4b9fa1d2ce1182e61290ff5190608c8b6a
Loading…
Cancel
Save