search of mempool started

master
moneroexamples 9 years ago
parent b8e758f259
commit ebc199e040

@ -1147,12 +1147,18 @@ namespace xmreg {
result_html = default_txt;
// get mempool transaction so that what we search,
// might be there. Note: show_tx above already searches it
// but only looks for tx hash. Now want to check
// for key_images, public_keys, payments_id, etc.
vector<transaction> mempool_txs = get_mempool_txs();
// now search my own custom lmdb database
// with key_images, public_keys, payments_id etc.
vector<pair<string, vector<string>>> all_possible_tx_hashes;
xmreg::MyLMDB mylmdb {"/home/mwo/.bitmonero/lmdb2"};
xmreg::MyLMDB mylmdb {mcore->get_blkchain_path()};
vector<string> tx_hashes;
mylmdb.search(search_text, tx_hashes, "key_images");
@ -1179,27 +1185,43 @@ namespace xmreg {
return result_html;
}
vector<transaction>
get_mempool_txs()
{
// get mempool data using rpc call
vector<pair<tx_info, transaction>> mempool_data = search_mempool();
// output only transactions
vector<transaction> mempool_txs;
mempool_txs.reserve(mempool_data.size());
for (const auto& a_pair: mempool_data)
{
mempool_txs.push_back(a_pair.second);
}
return mempool_txs;
}
string
show_search_results(const string& search_text,
const vector<pair<string, vector<string>>>& all_possible_tx_hashes)
{
// initalise page tempate map with basic info about blockchain
mstch::map context {
{"search_text", search_text},
{"search_text" , search_text},
{"no_results" , true},
{"to_many_results", false}
};
for (const pair<string, vector<string>>& found_txs: all_possible_tx_hashes)
{
// define flag, e.g., has_key_images denoting that
// tx hashes for key_image searched were found
context.insert({"has_" + found_txs.first, !found_txs.second.empty()});
// insert new array based on what we found to context if not exist
pair< mstch::map::iterator, bool> res
= context.insert({found_txs.first, mstch::array{}});
@ -1226,8 +1248,10 @@ namespace xmreg {
mstch::map txd_map = txd.get_mstch_map();
// get timestamp of the tx's block
uint64_t blk_height = core_storage->get_db().get_tx_block_height(txd.hash);
uint64_t blk_timestamp = core_storage->get_db().get_block_timestamp(blk_height);
uint64_t blk_height = core_storage
->get_db().get_tx_block_height(txd.hash);
uint64_t blk_timestamp = core_storage
->get_db().get_block_timestamp(blk_height);
// add the timestamp to tx mstch map
txd_map.insert({"timestamp", xmreg::timestamp_to_str(blk_timestamp)});
@ -1269,6 +1293,19 @@ namespace xmreg {
private:
map<string, vector<string>>
get_tx_keys(vector<tx_info> tx_infos)
{
map<string, vector<string>> tx_keys;
for (const tx_info& tx_info: tx_infos)
{
}
return tx_keys;
}
tx_details
get_tx_details(const transaction& tx, bool coinbase = false)
{
@ -1316,7 +1353,7 @@ namespace xmreg {
}
vector<pair<tx_info, transaction>>
search_mempool(crypto::hash tx_hash)
search_mempool(crypto::hash tx_hash = null_hash)
{
vector<pair<tx_info, transaction>> found_txs;
@ -1363,6 +1400,10 @@ namespace xmreg {
}
// if we dont provide tx_hash, just get all txs in
// the mempool
if (tx_hash != null_hash)
{
// check if tx hash matches, and if yes, save it for return
if (tx_hash == get_transaction_hash(tx))
{
@ -1370,6 +1411,12 @@ namespace xmreg {
break;
}
}
else
{
found_txs.push_back(make_pair(_tx_info, tx));
}
}
}
return found_txs;

@ -32,10 +32,10 @@
<td>Fee: {{tx_fee}}</td>
<td>Tx size: {{tx_size}} kB</td>
</tr>
<!-- <tr>
<tr>
<td colspan="5">Extra: {{extra}}</td>
</tr>
-->
</table>

Loading…
Cancel
Save