pushing tx disabled by default. enable-pusher flag added to enable it
This commit is contained in:
parent
207418432e
commit
b51b959036
15
main.cpp
15
main.cpp
|
@ -24,8 +24,9 @@ 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");
|
auto testnet_opt = opts.get_option<bool>("testnet");
|
||||||
|
auto enable_pusher_opt = opts.get_option<bool>("enable-pusher");
|
||||||
|
|
||||||
// if help was chosen, display help text and finish
|
// if help was chosen, display help text and finish
|
||||||
if (*help_opt)
|
if (*help_opt)
|
||||||
|
@ -33,13 +34,15 @@ int main(int ac, const char* av[]) {
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool testnet {*testnet_opt};
|
bool testnet {*testnet_opt};
|
||||||
|
bool enable_pusher {*enable_pusher_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");
|
||||||
auto deamon_url_opt = opts.get_option<string>("deamon-url");
|
auto deamon_url_opt = opts.get_option<string>("deamon-url");
|
||||||
|
|
||||||
|
|
||||||
//cast port number in string to uint16
|
//cast port number in string to uint16
|
||||||
uint16_t app_port = boost::lexical_cast<uint16_t>(*port_opt);
|
uint16_t app_port = boost::lexical_cast<uint16_t>(*port_opt);
|
||||||
|
|
||||||
|
@ -107,10 +110,12 @@ int main(int ac, const char* av[]) {
|
||||||
|
|
||||||
// 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,
|
deamon_url,
|
||||||
custom_db_path_str,
|
custom_db_path_str,
|
||||||
testnet);
|
testnet,
|
||||||
|
enable_pusher);
|
||||||
|
|
||||||
// crow instance
|
// crow instance
|
||||||
crow::SimpleApp app;
|
crow::SimpleApp app;
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace xmreg
|
||||||
"produce help message")
|
"produce help message")
|
||||||
("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
|
("testnet,t", value<bool>()->default_value(false)->implicit_value(true),
|
||||||
"use testnet blockchain")
|
"use testnet blockchain")
|
||||||
|
("enable-pusher", value<bool>()->default_value(false)->implicit_value(true),
|
||||||
|
"enable pushing signed tx")
|
||||||
("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>(),
|
||||||
|
|
20
src/page.h
20
src/page.h
|
@ -251,17 +251,21 @@ class page {
|
||||||
|
|
||||||
bool testnet;
|
bool testnet;
|
||||||
|
|
||||||
|
bool enable_pusher;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
page(MicroCore* _mcore, Blockchain* _core_storage,
|
page(MicroCore* _mcore, Blockchain* _core_storage,
|
||||||
string _deamon_url, string _lmdb2_path, bool _testnet)
|
string _deamon_url, string _lmdb2_path,
|
||||||
|
bool _testnet, bool _enable_pusher)
|
||||||
: 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}
|
testnet {_testnet},
|
||||||
|
enable_pusher {_enable_pusher}
|
||||||
{
|
{
|
||||||
css_styles = xmreg::read(TMPL_CSS_STYLES);
|
css_styles = xmreg::read(TMPL_CSS_STYLES);
|
||||||
}
|
}
|
||||||
|
@ -1960,6 +1964,18 @@ public:
|
||||||
|
|
||||||
string rpc_error_msg;
|
string rpc_error_msg;
|
||||||
|
|
||||||
|
if (this->enable_pusher == false)
|
||||||
|
{
|
||||||
|
string error_msg = fmt::format(
|
||||||
|
"Pushing signed transactions is disabled. "
|
||||||
|
"Run explorer with --enable-pusher flag to enable it.\n");
|
||||||
|
|
||||||
|
context["has_error"] = true;
|
||||||
|
context["error_msg"] = error_msg;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (!rpc.commit_tx(ptx, rpc_error_msg))
|
if (!rpc.commit_tx(ptx, rpc_error_msg))
|
||||||
{
|
{
|
||||||
string error_msg = fmt::format(
|
string error_msg = fmt::format(
|
||||||
|
|
Loading…
Reference in New Issue