mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-08-20 05:28:47 -06:00
Handle startup errors without calling abort()
This commit is contained in:
parent
1cf13e142a
commit
b191962d32
@ -85,10 +85,15 @@ int main(int argc, char* argv[])
|
|||||||
memory_tracking_start();
|
memory_tracking_start();
|
||||||
|
|
||||||
p2pool::init_crypto_cache();
|
p2pool::init_crypto_cache();
|
||||||
{
|
|
||||||
|
try {
|
||||||
p2pool::p2pool pool(argc, argv);
|
p2pool::p2pool pool(argc, argv);
|
||||||
result = pool.run();
|
result = pool.run();
|
||||||
}
|
}
|
||||||
|
catch (...) {
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
p2pool::destroy_crypto_cache();
|
p2pool::destroy_crypto_cache();
|
||||||
|
|
||||||
memory_tracking_stop();
|
memory_tracking_stop();
|
||||||
|
@ -61,13 +61,13 @@ p2pool::p2pool(int argc, char* argv[])
|
|||||||
|
|
||||||
if (!m_params->m_wallet.valid()) {
|
if (!m_params->m_wallet.valid()) {
|
||||||
LOGERR(1, "Invalid wallet address. Try \"p2pool --help\".");
|
LOGERR(1, "Invalid wallet address. Try \"p2pool --help\".");
|
||||||
panic();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_v6;
|
bool is_v6;
|
||||||
if (!resolve_host(m_params->m_host, is_v6)) {
|
if (!resolve_host(m_params->m_host, is_v6)) {
|
||||||
LOGERR(1, "resolve_host failed for " << m_params->m_host);
|
LOGERR(1, "resolve_host failed for " << m_params->m_host);
|
||||||
panic();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
hash pub, sec, eph_public_key;
|
hash pub, sec, eph_public_key;
|
||||||
@ -76,7 +76,7 @@ p2pool::p2pool(int argc, char* argv[])
|
|||||||
uint8_t view_tag;
|
uint8_t view_tag;
|
||||||
if (!m_params->m_wallet.get_eph_public_key(sec, 0, eph_public_key, view_tag)) {
|
if (!m_params->m_wallet.get_eph_public_key(sec, 0, eph_public_key, view_tag)) {
|
||||||
LOGERR(1, "Invalid wallet address: get_eph_public_key failed");
|
LOGERR(1, "Invalid wallet address: get_eph_public_key failed");
|
||||||
panic();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
const NetworkType type = m_params->m_wallet.type();
|
const NetworkType type = m_params->m_wallet.type();
|
||||||
@ -91,28 +91,28 @@ p2pool::p2pool(int argc, char* argv[])
|
|||||||
int err = uv_async_init(uv_default_loop_checked(), &m_submitBlockAsync, on_submit_block);
|
int err = uv_async_init(uv_default_loop_checked(), &m_submitBlockAsync, on_submit_block);
|
||||||
if (err) {
|
if (err) {
|
||||||
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
|
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
|
||||||
panic();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
m_submitBlockAsync.data = this;
|
m_submitBlockAsync.data = this;
|
||||||
|
|
||||||
err = uv_async_init(uv_default_loop_checked(), &m_blockTemplateAsync, on_update_block_template);
|
err = uv_async_init(uv_default_loop_checked(), &m_blockTemplateAsync, on_update_block_template);
|
||||||
if (err) {
|
if (err) {
|
||||||
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
|
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
|
||||||
panic();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
m_blockTemplateAsync.data = this;
|
m_blockTemplateAsync.data = this;
|
||||||
|
|
||||||
err = uv_async_init(uv_default_loop_checked(), &m_stopAsync, on_stop);
|
err = uv_async_init(uv_default_loop_checked(), &m_stopAsync, on_stop);
|
||||||
if (err) {
|
if (err) {
|
||||||
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
|
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
|
||||||
panic();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
m_stopAsync.data = this;
|
m_stopAsync.data = this;
|
||||||
|
|
||||||
err = uv_async_init(uv_default_loop_checked(), &m_restartZMQAsync, on_restart_zmq);
|
err = uv_async_init(uv_default_loop_checked(), &m_restartZMQAsync, on_restart_zmq);
|
||||||
if (err) {
|
if (err) {
|
||||||
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
|
LOGERR(1, "uv_async_init failed, error " << uv_err_name(err));
|
||||||
panic();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
m_restartZMQAsync.data = this;
|
m_restartZMQAsync.data = this;
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ p2pool::p2pool(int argc, char* argv[])
|
|||||||
|
|
||||||
if (m_params->m_localStats && !m_api) {
|
if (m_params->m_localStats && !m_api) {
|
||||||
LOGERR(1, "--local-api and --stratum-api command line parameters can't be used without --data-api");
|
LOGERR(1, "--local-api and --stratum-api command line parameters can't be used without --data-api");
|
||||||
panic();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_sideChain = new SideChain(this, type, m_params->m_mini ? "mini" : nullptr);
|
m_sideChain = new SideChain(this, type, m_params->m_mini ? "mini" : nullptr);
|
||||||
|
@ -133,7 +133,7 @@ Params::Params(int argc, char* argv[])
|
|||||||
if (!ok) {
|
if (!ok) {
|
||||||
fprintf(stderr, "Unknown command line parameter %s\n\n", argv[i]);
|
fprintf(stderr, "Unknown command line parameter %s\n\n", argv[i]);
|
||||||
p2pool_usage();
|
p2pool_usage();
|
||||||
panic();
|
throw std::exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user