Make it easier to insert code between when the server is setup and when it's started.

This commit is contained in:
JoelKatz
2013-01-09 23:55:39 -08:00
parent 1e2b11fe80
commit 376f214a70
3 changed files with 12 additions and 2 deletions

View File

@@ -81,7 +81,7 @@ void sigIntHandler(int)
} }
#endif #endif
void Application::run() void Application::setup()
{ {
#ifndef WIN32 #ifndef WIN32
#ifdef SIGINT #ifdef SIGINT
@@ -256,7 +256,10 @@ void Application::run()
} }
else else
mNetOps.setStateTimer(); mNetOps.setStateTimer();
}
void Application::run()
{
mIOService.run(); // This blocks mIOService.run(); // This blocks
if (mWSPublicDoor) if (mWSPublicDoor)

View File

@@ -133,6 +133,7 @@ public:
uint256 getNonce256() { return mNonce256; } uint256 getNonce256() { return mNonce256; }
std::size_t getNonceST() { return mNonceST; } std::size_t getNonceST() { return mNonceST; }
void setup();
void run(); void run();
void stop(); void stop();
void sweep(); void sweep();

View File

@@ -17,9 +17,14 @@ extern bool AddSystemEntropy();
using namespace std; using namespace std;
using namespace boost::unit_test; using namespace boost::unit_test;
void startServer() void setupServer()
{ {
theApp = new Application(); theApp = new Application();
theApp->setup();
}
void startServer()
{
theApp->run(); // Blocks till we get a stop RPC. theApp->run(); // Blocks till we get a stop RPC.
} }
@@ -194,6 +199,7 @@ int main(int argc, char* argv[])
else if (!vm.count("parameters")) else if (!vm.count("parameters"))
{ {
// No arguments. Run server. // No arguments. Run server.
setupServer();
startServer(); startServer();
} }
else else