From 2155513e4a8c3d856ff0df4a6f6e9ab7e0835b86 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 13 Aug 2014 14:28:49 -0400 Subject: [PATCH] whitespace --- work.cpp | 116 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 60 insertions(+), 56 deletions(-) diff --git a/work.cpp b/work.cpp index b57584da..23ab0549 100644 --- a/work.cpp +++ b/work.cpp @@ -597,68 +597,72 @@ using namespace std; using namespace boost; namespace { - const int MAX_OUTBOUND_CONNECTIONS = 8; + const int MAX_OUTBOUND_CONNECTIONS = 8; - struct ListenSocket { - SOCKET socket; - bool whitelisted; + struct ListenSocket { + SOCKET socket; + bool whitelisted; - ListenSocket(SOCKET socket, bool whitelisted) : socket(socket), whitelisted(whitelisted) {} - }; + ListenSocket(SOCKET socket, bool whitelisted) : socket(socket), whitelisted(whitelisted) {} + }; } -void StartNode(boost::thread_group& threadGroup) -{ - if (semOutbound == NULL) { - // initialize semaphore - int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections); - semOutbound = new CSemaphore(nMaxOutbound); +void StartNode(boost::thread_group& threadGroup) { + if (semOutbound == NULL) { + // initialize semaphore + int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections); + semOutbound = new CSemaphore(nMaxOutbound); + } + + if (pnodeLocalHost == NULL) { + pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); + } + + Discover(threadGroup); + + // + // Start threads + // + + if (!GetBoolArg("-dnsseed", true)) { + LogPrintf("DNS seeding disabled\n"); + } else { + threadGroup.create_thread(boost::bind(&TraceThread, "dnsseed", &ThreadDNSAddressSeed)); + } + + // Map ports with UPnP + MapPort(GetBoolArg("-upnp", DEFAULT_UPNP)); + + // Send and receive from sockets, accept connections + threadGroup.create_thread(boost::bind(&TraceThread, "net", &ThreadSocketHandler)); + + // Initiate outbound connections from -addnode + threadGroup.create_thread(boost::bind(&TraceThread, "addcon", &ThreadOpenAddedConnections)); + + // Initiate outbound connections + threadGroup.create_thread(boost::bind(&TraceThread, "opencon", &ThreadOpenConnections)); + + // Process messages + threadGroup.create_thread(boost::bind(&TraceThread, "msghand", &ThreadMessageHandler)); + + // Dump network addresses + threadGroup.create_thread(boost::bind(&LoopForever, "dumpaddr", + &DumpAddresses, DUMP_ADDRESSES_INTERVAL * 1000)); +} + +bool StopNode() { + LogPrintf("StopNode()\n"); + MapPort(false); + + if (semOutbound) { + for (int i = 0; i < MAX_OUTBOUND_CONNECTIONS; i++) { + semOutbound->post(); } + } - if (pnodeLocalHost == NULL) - pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService("127.0.0.1", 0), nLocalServices)); + MilliSleep(50); + DumpAddresses(); - Discover(threadGroup); - - // - // Start threads - // - - if (!GetBoolArg("-dnsseed", true)) - LogPrintf("DNS seeding disabled\n"); - else - threadGroup.create_thread(boost::bind(&TraceThread, "dnsseed", &ThreadDNSAddressSeed)); - - // Map ports with UPnP - MapPort(GetBoolArg("-upnp", DEFAULT_UPNP)); - - // Send and receive from sockets, accept connections - threadGroup.create_thread(boost::bind(&TraceThread, "net", &ThreadSocketHandler)); - - // Initiate outbound connections from -addnode - threadGroup.create_thread(boost::bind(&TraceThread, "addcon", &ThreadOpenAddedConnections)); - - // Initiate outbound connections - threadGroup.create_thread(boost::bind(&TraceThread, "opencon", &ThreadOpenConnections)); - - // Process messages - threadGroup.create_thread(boost::bind(&TraceThread, "msghand", &ThreadMessageHandler)); - - // Dump network addresses - threadGroup.create_thread(boost::bind(&LoopForever, "dumpaddr", &DumpAddresses, DUMP_ADDRESSES_INTERVAL * 1000)); + return true; } - -bool StopNode() -{ - LogPrintf("StopNode()\n"); - MapPort(false); - if (semOutbound) - for (int i=0; ipost(); - MilliSleep(50); - DumpAddresses(); - - return true; -} -