mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
custom search results im mylmdb added
This commit is contained in:
parent
9d41c78793
commit
d5a46bf914
7 changed files with 119 additions and 36 deletions
|
@ -112,6 +112,7 @@ endmacro(configure_files)
|
|||
|
||||
configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates ${CMAKE_CURRENT_BINARY_DIR}/templates)
|
||||
configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates/css ${CMAKE_CURRENT_BINARY_DIR}/templates/css)
|
||||
configure_files(${CMAKE_CURRENT_SOURCE_DIR}/src/templates/partials ${CMAKE_CURRENT_BINARY_DIR}/templates/partials)
|
||||
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
|
|
|
@ -135,6 +135,29 @@ namespace xmreg
|
|||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
MicroCore::get_tx(const string& tx_hash_str, transaction& tx)
|
||||
{
|
||||
|
||||
// parse tx hash string to hash object
|
||||
crypto::hash tx_hash;
|
||||
|
||||
if (!xmreg::parse_str_secret_key(tx_hash_str, tx_hash))
|
||||
{
|
||||
cerr << "Cant parse tx hash: " << tx_hash_str << endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!get_tx(tx_hash, tx))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -46,6 +46,9 @@ namespace xmreg
|
|||
bool
|
||||
get_tx(const crypto::hash& tx_hash, transaction& tx);
|
||||
|
||||
bool
|
||||
get_tx(const string& tx_hash, transaction& tx);
|
||||
|
||||
bool
|
||||
find_output_in_tx(const transaction& tx,
|
||||
const public_key& output_pubkey,
|
||||
|
|
35
src/page.h
35
src/page.h
|
@ -25,6 +25,7 @@
|
|||
#include <ctime>
|
||||
|
||||
#define TMPL_DIR "./templates"
|
||||
#define TMPL_PARIALS_DIR TMPL_DIR "/partials"
|
||||
#define TMPL_INDEX TMPL_DIR "/index.html"
|
||||
#define TMPL_MEMPOOL TMPL_DIR "/mempool.html"
|
||||
#define TMPL_HEADER TMPL_DIR "/header.html"
|
||||
|
@ -969,9 +970,9 @@ namespace xmreg {
|
|||
// initalise page tempate map with basic info about blockchain
|
||||
mstch::map context {
|
||||
{"search_text", search_text},
|
||||
{"no_results" , true},
|
||||
};
|
||||
|
||||
string out_tmp {"Searching for: " + search_text + string("<br/>")};
|
||||
|
||||
for (const pair<string, vector<string>>& found_txs: all_possible_tx_hashes)
|
||||
{
|
||||
|
@ -985,25 +986,29 @@ namespace xmreg {
|
|||
pair< mstch::map::iterator, bool> res
|
||||
= context.insert({found_txs.first, mstch::array{}});
|
||||
|
||||
|
||||
if (!found_txs.second.empty())
|
||||
{
|
||||
out_tmp += found_txs.first + string("<br/>");
|
||||
|
||||
cout << "found_txs.first: " << found_txs.first << endl;
|
||||
|
||||
// for each found tx_hash, get the corresponding tx
|
||||
// and its details, and put into mstch for rendering
|
||||
for (const string& tx_hash: found_txs.second)
|
||||
{
|
||||
|
||||
boost::get<mstch::array>((res.first)->second).push_back(
|
||||
mstch::map {{"tx_hash", tx_hash}}
|
||||
);
|
||||
transaction tx;
|
||||
|
||||
out_tmp += string(" - ")
|
||||
+ fmt::format("{:s}", tx_hash)
|
||||
+ string("<br/>");
|
||||
if (!mcore->get_tx(tx_hash, tx))
|
||||
{
|
||||
return string("Cant get tx of hash: " + tx_hash);
|
||||
}
|
||||
|
||||
tx_details txd = get_tx_details(tx);
|
||||
|
||||
boost::get<mstch::array>((res.first)->second).push_back(txd.get_mstch_map());
|
||||
}
|
||||
|
||||
// if found something, set this flag to indicate this fact
|
||||
context["no_results"] = false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1013,8 +1018,14 @@ namespace xmreg {
|
|||
// add header and footer
|
||||
string full_page = get_full_page(search_results_html);
|
||||
|
||||
// read partial for showing details of tx(s) found
|
||||
map<string, string> partials {
|
||||
{"tx_table_head", xmreg::read(string(TMPL_PARIALS_DIR) + "/tx_table_header.html")},
|
||||
{"tx_table_row" , xmreg::read(string(TMPL_PARIALS_DIR) + "/tx_table_row.html")}
|
||||
};
|
||||
|
||||
// render the page
|
||||
return mstch::render(full_page, context);
|
||||
return mstch::render(full_page, context, partials);
|
||||
}
|
||||
|
||||
|
||||
|
|
8
src/templates/partials/tx_table_header.html
Normal file
8
src/templates/partials/tx_table_header.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<tr>
|
||||
<td>tx hash</td>
|
||||
<td>outputs</td>
|
||||
<td>fee</td>
|
||||
<td>mixin</td>
|
||||
<td>in/out</td>
|
||||
<td>size [kB]</td>
|
||||
</tr>
|
8
src/templates/partials/tx_table_row.html
Normal file
8
src/templates/partials/tx_table_row.html
Normal file
|
@ -0,0 +1,8 @@
|
|||
<tr>
|
||||
<td><a href="/tx/{{hash}}">{{hash}}</a></td>
|
||||
<td>{{sum_outputs}}</td>
|
||||
<td>{{tx_fee}}</td>
|
||||
<td>{{mixin}}</td>
|
||||
<td>{{no_inputs}}/{{no_outputs}}</td>
|
||||
<td>{{tx_size}}</td>
|
||||
</tr>
|
|
@ -1,46 +1,75 @@
|
|||
<H4 style="margin:5px">Search results</H4>
|
||||
<h5> Looking for {{search_text}} </h5>
|
||||
|
||||
<h3> Search results for: {{search_text}} </h3>
|
||||
|
||||
{{#no_results}}
|
||||
<h4>Nothing has been found that matches the search term :-(</h4>
|
||||
{{/no_results}}
|
||||
|
||||
<div>
|
||||
|
||||
|
||||
{{#has_key_images}}
|
||||
|
||||
<h3>This key image found in the following transactions</h3>
|
||||
<ul>
|
||||
<h3>The search term matches key image found in the following transactions</h3>
|
||||
|
||||
<table class="center" style="width:80%">
|
||||
{{>tx_table_head}}
|
||||
{{#key_images}}
|
||||
<li>{{tx_hash}}</li>
|
||||
{{>tx_table_row}}
|
||||
{{/key_images}}
|
||||
</ul>
|
||||
</table>
|
||||
|
||||
{{/has_key_images}}
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
{{#has_tx_public_keys}}
|
||||
|
||||
<h3>The search term matches tx public key found in the following transactions</h3>
|
||||
|
||||
<table class="center" style="width:80%">
|
||||
{{>tx_table_head}}
|
||||
{{#tx_public_keys}}
|
||||
{{tx_hash}} </br>
|
||||
{{>tx_table_row}}
|
||||
{{/tx_public_keys}}
|
||||
</table>
|
||||
|
||||
{{/has_tx_public_keys}}
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
{{#has_payments_id}}
|
||||
|
||||
<h3>The search term matches payment id found in the following transactions</h3>
|
||||
|
||||
<table class="center" style="width:80%">
|
||||
{{>tx_table_head}}
|
||||
{{#payments_id}}
|
||||
{{tx_hash}} </br>
|
||||
{{>tx_table_row}}
|
||||
{{/payments_id}}
|
||||
</table>
|
||||
|
||||
{{/has_payments_id}}
|
||||
|
||||
</div>
|
||||
|
||||
<div>
|
||||
|
||||
{{#has_output_public_keys}}
|
||||
|
||||
<h3>The search term matches output public key found in the following transactions</h3>
|
||||
|
||||
<table class="center" style="width:80%">
|
||||
{{>tx_table_head}}
|
||||
{{#output_public_keys}}
|
||||
{{tx_hash}} </br>
|
||||
{{>tx_table_row}}
|
||||
{{/output_public_keys}}
|
||||
</table>
|
||||
|
||||
{{/has_output_public_keys}}
|
||||
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in a new issue