mirror of
https://github.com/EvernodeXRPL/hpcore.git
synced 2026-04-29 15:37:59 +00:00
Loading and saving ledger and lcl consensus. (#51)
* Ledger saving, loading, consensus with ledger sequence number. * std terminate exception handler.
This commit is contained in:
committed by
Ravin Perera
parent
b8ffb83869
commit
b598025346
55
src/main.cpp
55
src/main.cpp
@@ -78,8 +78,47 @@ void signal_handler(int signum)
|
||||
exit(signum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global exception handler for boost exceptions.
|
||||
*/
|
||||
void boost::throw_exception(std::exception const &e)
|
||||
{
|
||||
LOG_ERR << "Boost error:" << e.what();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global exception handler for std exceptions.
|
||||
*/
|
||||
void std_terminate() noexcept
|
||||
{
|
||||
std::exception_ptr exptr = std::current_exception();
|
||||
if (exptr != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
std::rethrow_exception(exptr);
|
||||
}
|
||||
catch (std::exception &ex)
|
||||
{
|
||||
LOG_ERR << "std error: " << ex.what();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
LOG_ERR << "std error: Terminated due to unknown exception";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERR << "std error: Terminated due to unknown reason";
|
||||
}
|
||||
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
std::set_terminate(&std_terminate);
|
||||
// Extract the CLI args
|
||||
// This call will populate conf::ctx
|
||||
if (parse_cmd(argc, argv) != 0)
|
||||
@@ -129,11 +168,15 @@ int main(int argc, char **argv)
|
||||
if (usr::init() != 0)
|
||||
return -1;
|
||||
|
||||
if (cons::init() != 0)
|
||||
return 1;
|
||||
|
||||
// After initializing primary subsystems, register the SIGINT handler.
|
||||
signal(SIGINT, signal_handler);
|
||||
|
||||
cons::ctx.stage = 0;
|
||||
cons::ctx.lcl = "static_lcl";
|
||||
//we are waiting for peer to estasblish peer connections.
|
||||
//otherwise we'll run into not enough peers propsing/stage desync deadlock directly now.
|
||||
sleep(3);
|
||||
|
||||
while (true)
|
||||
{
|
||||
@@ -150,11 +193,3 @@ int main(int argc, char **argv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global exception handler for boost exceptions.
|
||||
*/
|
||||
void boost::throw_exception(std::exception const &e)
|
||||
{
|
||||
LOG_ERR << "Boost error:" << e.what();
|
||||
exit(-1);
|
||||
}
|
||||
Reference in New Issue
Block a user