aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2016-05-26 23:29:39 -0400
committerCory Fields <cory-nospam-@coryfields.com>2016-09-08 12:24:07 -0400
commitbafa5fc5a1ba33337b5eb3d8ae24ba2fac2949f8 (patch)
tree5d166b29ad0378d7e8394e21271ad9863d515b3f /src
parente81a602cf02edfb21c3ec097bd7cf71f189ed783 (diff)
net: Drop StartNode/StopNode and use CConnman directly
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp10
-rw-r--r--src/net.cpp24
-rw-r--r--src/net.h3
3 files changed, 11 insertions, 26 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 9e2ed62a92..4e1c8e1b61 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -199,7 +199,8 @@ void Shutdown()
if (pwalletMain)
pwalletMain->Flush(false);
#endif
- StopNode(*g_connman);
+ MapPort(false);
+ g_connman->Stop();
g_connman.reset();
StopTorControl();
@@ -1508,9 +1509,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION))
StartTorControl(threadGroup, scheduler);
+ Discover(threadGroup);
+
+ // Map ports with UPnP
+ MapPort(GetBoolArg("-upnp", DEFAULT_UPNP));
+
std::string strNodeError;
int nMaxOutbound = std::min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
- if(!StartNode(connman, threadGroup, scheduler, nLocalServices, nRelevantServices, nMaxConnections, nMaxOutbound, chainActive.Height(), &uiInterface, strNodeError))
+ if(!connman.Start(threadGroup, scheduler, nLocalServices, nRelevantServices, nMaxConnections, nMaxOutbound, chainActive.Height(), &uiInterface, strNodeError))
return InitError(strNodeError);
// ********************************************************* Step 12: finished
diff --git a/src/net.cpp b/src/net.cpp
index 13218b4221..15c066cd7c 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1979,7 +1979,7 @@ bool CConnman::BindListenPort(const CService &addrBind, std::string& strError, b
return true;
}
-void static Discover(boost::thread_group& threadGroup)
+void Discover(boost::thread_group& threadGroup)
{
if (!fDiscover)
return;
@@ -2044,15 +2044,6 @@ CConnman::CConnman()
clientInterface = NULL;
}
-bool StartNode(CConnman& connman, boost::thread_group& threadGroup, CScheduler& scheduler, ServiceFlags nLocalServices, ServiceFlags nRelevantServices, int nMaxConnectionsIn, int nMaxOutboundIn, int nBestHeightIn, CClientUIInterface* interfaceIn, std::string& strNodeError)
-{
- Discover(threadGroup);
-
- bool ret = connman.Start(threadGroup, scheduler, nLocalServices, nRelevantServices, nMaxConnectionsIn, nMaxOutboundIn, nBestHeightIn, interfaceIn, strNodeError);
-
- return ret;
-}
-
NodeId CConnman::GetNewNodeId()
{
return nLastNodeId.fetch_add(1, std::memory_order_relaxed);
@@ -2136,9 +2127,6 @@ bool CConnman::Start(boost::thread_group& threadGroup, CScheduler& scheduler, Se
else
threadGroup.create_thread(boost::bind(&TraceThread<boost::function<void()> >, "dnsseed", boost::function<void()>(boost::bind(&CConnman::ThreadDNSAddressSeed, this))));
- // Map ports with UPnP
- MapPort(GetBoolArg("-upnp", DEFAULT_UPNP));
-
// Send and receive from sockets, accept connections
threadGroup.create_thread(boost::bind(&TraceThread<boost::function<void()> >, "net", boost::function<void()>(boost::bind(&CConnman::ThreadSocketHandler, this))));
@@ -2157,15 +2145,6 @@ bool CConnman::Start(boost::thread_group& threadGroup, CScheduler& scheduler, Se
return true;
}
-bool StopNode(CConnman& connman)
-{
- LogPrintf("StopNode()\n");
- MapPort(false);
-
- connman.Stop();
- return true;
-}
-
class CNetCleanup
{
public:
@@ -2183,6 +2162,7 @@ instance_of_cnetcleanup;
void CConnman::Stop()
{
+ LogPrintf("%s\n",__func__);
if (semOutbound)
for (int i=0; i<(nMaxOutbound + MAX_FEELER_CONNECTIONS); i++)
semOutbound->post();
diff --git a/src/net.h b/src/net.h
index a45e18da67..e08409e81e 100644
--- a/src/net.h
+++ b/src/net.h
@@ -298,11 +298,10 @@ private:
CClientUIInterface* clientInterface;
};
extern std::unique_ptr<CConnman> g_connman;
+void Discover(boost::thread_group& threadGroup);
void MapPort(bool fUseUPnP);
unsigned short GetListenPort();
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
-bool StartNode(CConnman& connman, boost::thread_group& threadGroup, CScheduler& scheduler, ServiceFlags nLocalServices, ServiceFlags nRelevantServices, int nMaxConnections, int nMaxOutbound, int nBestHeightIn, CClientUIInterface* interfaceIn, std::string& strNodeError);
-bool StopNode(CConnman& connman);
size_t SocketSendData(CNode *pnode);
struct CombinerAll