From 87c32325519fcd1c4ef4e11a1c3e06ae5cfa879e Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 28 Apr 2016 04:18:49 +0000 Subject: [PATCH] searching for tx coitaining given key image or public key added --- src/mylmdb.h | 4 ++-- src/page.h | 25 +++++++++++++++++++++---- src/templates/header.html | 3 ++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/mylmdb.h b/src/mylmdb.h index 77ca8b8..61e24c9 100644 --- a/src/mylmdb.h +++ b/src/mylmdb.h @@ -226,14 +226,14 @@ namespace xmreg // set cursor the the first item if (cr.get(key_to_find, tx_hash_val, MDB_SET)) { - cout << key_val_to_str(key_to_find, tx_hash_val) << endl; + //cout << key_val_to_str(key_to_find, tx_hash_val) << endl; out.push_back(string(tx_hash_val.data(), tx_hash_val.size())); // process other values for the same key while (cr.get(key_to_find, tx_hash_val, MDB_NEXT_DUP)) { - cout << key_val_to_str(key_to_find, tx_hash_val) << endl; + //cout << key_val_to_str(key_to_find, tx_hash_val) << endl; out.push_back(string(tx_hash_val.data(), tx_hash_val.size())); diff --git a/src/page.h b/src/page.h index 8460363..522bd7e 100644 --- a/src/page.h +++ b/src/page.h @@ -18,6 +18,7 @@ #include "MicroCore.h" #include "tools.h" #include "rpccalls.h" +#include "mylmdb.h" #include #include @@ -594,7 +595,7 @@ namespace xmreg { if (!xmreg::parse_str_secret_key(_blk_hash, blk_hash)) { cerr << "Cant parse blk hash: " << blk_hash << endl; - return fmt::format("Cant parse block hash {:s}!", blk_hash); + return fmt::format("Cant get block {:s}!", blk_hash); } uint64_t blk_height; @@ -606,12 +607,12 @@ namespace xmreg { catch (const BLOCK_DNE& e) { cerr << "Block does not exist: " << blk_hash << endl; - return fmt::format("Block of hash {:s} does not exist!", blk_hash); + return fmt::format("Cant get block {:s}!", blk_hash); } catch (const std::exception& e) { cerr << "Cant get block: " << blk_hash << endl; - return fmt::format("Block of hash {:s} not found!", blk_hash); + return fmt::format("Cant get block {:s}!", blk_hash); } return show_block(blk_height); @@ -931,6 +932,23 @@ namespace xmreg { return result_html; } + xmreg::MyLMDB mylmdb {"/home/mwo/.bitmonero/lmdb2"}; + + vector tx_hashes = mylmdb.search(search_text, "key_images"); + + if (tx_hashes.size() == 1) + { + result_html = show_tx(tx_hashes.at(0)); + return result_html; + } + + tx_hashes = mylmdb.search(search_text, "public_keys"); + + if (tx_hashes.size() == 1) + { + result_html = show_tx(tx_hashes.at(0)); + return result_html; + } return result_html; } @@ -938,7 +956,6 @@ namespace xmreg { private: - tx_details get_tx_details(const transaction& tx, bool coinbase = false) { diff --git a/src/templates/header.html b/src/templates/header.html index e081e08..59ec9f7 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -86,7 +86,8 @@
- +