mirror of
https://git.wownero.com/wownero/onion-wownero-blockchain-explorer.git
synced 2024-08-15 00:33:12 +00:00
testnet option added to xmrblocks
This commit is contained in:
parent
f9925d6c3b
commit
c23213cd89
6 changed files with 39 additions and 12 deletions
19
main.cpp
19
main.cpp
|
@ -24,7 +24,8 @@ int main(int ac, const char* av[]) {
|
||||||
// get command line options
|
// get command line options
|
||||||
xmreg::CmdLineOptions opts {ac, av};
|
xmreg::CmdLineOptions opts {ac, av};
|
||||||
|
|
||||||
auto help_opt = opts.get_option<bool>("help");
|
auto help_opt = opts.get_option<bool>("help");
|
||||||
|
auto testnet_opt = opts.get_option<bool>("testnet");
|
||||||
|
|
||||||
// if help was chosen, display help text and finish
|
// if help was chosen, display help text and finish
|
||||||
if (*help_opt)
|
if (*help_opt)
|
||||||
|
@ -32,6 +33,8 @@ int main(int ac, const char* av[]) {
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool testnet {*testnet_opt};
|
||||||
|
|
||||||
auto port_opt = opts.get_option<string>("port");
|
auto port_opt = opts.get_option<string>("port");
|
||||||
auto bc_path_opt = opts.get_option<string>("bc-path");
|
auto bc_path_opt = opts.get_option<string>("bc-path");
|
||||||
auto custom_db_path_opt = opts.get_option<string>("custom-db-path");
|
auto custom_db_path_opt = opts.get_option<string>("custom-db-path");
|
||||||
|
@ -43,12 +46,14 @@ int main(int ac, const char* av[]) {
|
||||||
// get blockchain path
|
// get blockchain path
|
||||||
path blockchain_path;
|
path blockchain_path;
|
||||||
|
|
||||||
if (!xmreg::get_blockchain_path(bc_path_opt, blockchain_path))
|
if (!xmreg::get_blockchain_path(bc_path_opt, blockchain_path, testnet))
|
||||||
{
|
{
|
||||||
cerr << "Error getting blockchain path." << endl;
|
cerr << "Error getting blockchain path." << endl;
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << blockchain_path << endl;
|
||||||
|
|
||||||
// enable basic monero log output
|
// enable basic monero log output
|
||||||
xmreg::enable_monero_log();
|
xmreg::enable_monero_log();
|
||||||
|
|
||||||
|
@ -94,10 +99,18 @@ int main(int ac, const char* av[]) {
|
||||||
custom_db_path_str = xmreg::remove_trailing_path_separator(custom_db_path_str);
|
custom_db_path_str = xmreg::remove_trailing_path_separator(custom_db_path_str);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string deamon_url {*deamon_url_opt};
|
||||||
|
|
||||||
|
if (testnet)
|
||||||
|
deamon_url = "http:://127.0.0.1:28081";
|
||||||
|
|
||||||
// create instance of page class which
|
// create instance of page class which
|
||||||
// contains logic for the website
|
// contains logic for the website
|
||||||
xmreg::page xmrblocks(&mcore, core_storage,
|
xmreg::page xmrblocks(&mcore, core_storage,
|
||||||
*deamon_url_opt, custom_db_path_str);
|
deamon_url,
|
||||||
|
custom_db_path_str,
|
||||||
|
testnet);
|
||||||
|
|
||||||
// crow instance
|
// crow instance
|
||||||
crow::SimpleApp app;
|
crow::SimpleApp app;
|
||||||
|
|
|
@ -23,6 +23,8 @@ namespace xmreg
|
||||||
desc.add_options()
|
desc.add_options()
|
||||||
("help,h", value<bool>()->default_value(false)->implicit_value(true),
|
("help,h", value<bool>()->default_value(false)->implicit_value(true),
|
||||||
"produce help message")
|
"produce help message")
|
||||||
|
("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
|
||||||
|
"use testnet blockchain")
|
||||||
("port,p", value<string>()->default_value("8081"),
|
("port,p", value<string>()->default_value("8081"),
|
||||||
"default port")
|
"default port")
|
||||||
("bc-path,b", value<string>(),
|
("bc-path,b", value<string>(),
|
||||||
|
|
|
@ -234,16 +234,19 @@ namespace xmreg {
|
||||||
|
|
||||||
string lmdb2_path;
|
string lmdb2_path;
|
||||||
|
|
||||||
|
bool testnet;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
page(MicroCore* _mcore, Blockchain* _core_storage,
|
page(MicroCore* _mcore, Blockchain* _core_storage,
|
||||||
string _deamon_url, string _lmdb2_path)
|
string _deamon_url, string _lmdb2_path, bool _testnet)
|
||||||
: mcore {_mcore},
|
: mcore {_mcore},
|
||||||
core_storage {_core_storage},
|
core_storage {_core_storage},
|
||||||
rpc {_deamon_url},
|
rpc {_deamon_url},
|
||||||
server_timestamp {std::time(nullptr)},
|
server_timestamp {std::time(nullptr)},
|
||||||
lmdb2_path {_lmdb2_path}
|
lmdb2_path {_lmdb2_path},
|
||||||
|
testnet {_testnet}
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -972,6 +975,7 @@ namespace xmreg {
|
||||||
{"tx_size" , fmt::format("{:0.4f}",
|
{"tx_size" , fmt::format("{:0.4f}",
|
||||||
static_cast<double>(txd.size) / 1024.0)},
|
static_cast<double>(txd.size) / 1024.0)},
|
||||||
{"tx_fee" , fmt::format("{:0.12f}", XMR_AMOUNT(txd.fee))},
|
{"tx_fee" , fmt::format("{:0.12f}", XMR_AMOUNT(txd.fee))},
|
||||||
|
{"tx_version" , fmt::format("{:d}", txd.version)},
|
||||||
{"blk_timestamp" , blk_timestamp},
|
{"blk_timestamp" , blk_timestamp},
|
||||||
{"blk_timestamp_uint" , blk.timestamp},
|
{"blk_timestamp_uint" , blk.timestamp},
|
||||||
{"delta_time" , age.first},
|
{"delta_time" , age.first},
|
||||||
|
|
|
@ -35,6 +35,9 @@
|
||||||
<td>Fee: {{tx_fee}}</td>
|
<td>Fee: {{tx_fee}}</td>
|
||||||
<td>Tx size: {{tx_size}} kB</td>
|
<td>Tx size: {{tx_size}} kB</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Tx version: {{tx_version}}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5">Extra: {{extra}}</td>
|
<td colspan="5">Extra: {{extra}}</td>
|
||||||
|
|
|
@ -223,12 +223,16 @@ namespace xmreg
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
get_default_lmdb_folder()
|
get_default_lmdb_folder(bool testnet)
|
||||||
{
|
{
|
||||||
// default path to monero folder
|
// default path to monero folder
|
||||||
// on linux this is /home/<username>/.bitmonero
|
// on linux this is /home/<username>/.bitmonero
|
||||||
string default_monero_dir = tools::get_default_data_dir();
|
string default_monero_dir = tools::get_default_data_dir();
|
||||||
|
|
||||||
|
if (testnet)
|
||||||
|
default_monero_dir += "/testnet";
|
||||||
|
|
||||||
|
|
||||||
// the default folder of the lmdb blockchain database
|
// the default folder of the lmdb blockchain database
|
||||||
// is therefore as follows
|
// is therefore as follows
|
||||||
return default_monero_dir + string("/lmdb");
|
return default_monero_dir + string("/lmdb");
|
||||||
|
@ -241,17 +245,17 @@ namespace xmreg
|
||||||
* If not given, provide default path
|
* If not given, provide default path
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
get_blockchain_path(const boost::optional<string>& bc_path, bf::path& blockchain_path )
|
get_blockchain_path(const boost::optional<string>& bc_path,
|
||||||
|
bf::path& blockchain_path,
|
||||||
|
bool testnet)
|
||||||
{
|
{
|
||||||
// the default folder of the lmdb blockchain database
|
// the default folder of the lmdb blockchain database
|
||||||
string default_lmdb_dir = xmreg::get_default_lmdb_folder();
|
string default_lmdb_dir = xmreg::get_default_lmdb_folder(testnet);
|
||||||
|
|
||||||
blockchain_path = bc_path
|
blockchain_path = bc_path
|
||||||
? bf::path(*bc_path)
|
? bf::path(*bc_path)
|
||||||
: bf::path(default_lmdb_dir);
|
: bf::path(default_lmdb_dir);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!bf::is_directory(blockchain_path))
|
if (!bf::is_directory(blockchain_path))
|
||||||
{
|
{
|
||||||
cerr << "Given path \"" << blockchain_path << "\" "
|
cerr << "Given path \"" << blockchain_path << "\" "
|
||||||
|
|
|
@ -118,7 +118,7 @@ namespace xmreg
|
||||||
|
|
||||||
|
|
||||||
string
|
string
|
||||||
get_default_lmdb_folder();
|
get_default_lmdb_folder(bool testnet = false);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
generate_key_image(const crypto::key_derivation& derivation,
|
generate_key_image(const crypto::key_derivation& derivation,
|
||||||
|
@ -129,7 +129,8 @@ namespace xmreg
|
||||||
|
|
||||||
bool
|
bool
|
||||||
get_blockchain_path(const boost::optional<string>& bc_path,
|
get_blockchain_path(const boost::optional<string>& bc_path,
|
||||||
bf::path& blockchain_path);
|
bf::path& blockchain_path,
|
||||||
|
bool testnet = false);
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
sum_money_in_outputs(const transaction& tx);
|
sum_money_in_outputs(const transaction& tx);
|
||||||
|
|
Loading…
Reference in a new issue