@@ -1674,15 +1674,15 @@ void CConnman::ProcessOneShot()
1674
1674
}
1675
1675
}
1676
1676
1677
- void CConnman::ThreadOpenConnections ()
1677
+ void CConnman::ThreadOpenConnections (const std::vector<std::string> connect )
1678
1678
{
1679
1679
// Connect to specific addresses
1680
- if (gArgs . IsArgSet ( " -connect " ))
1680
+ if (!connect. empty ( ))
1681
1681
{
1682
1682
for (int64_t nLoop = 0 ;; nLoop++)
1683
1683
{
1684
1684
ProcessOneShot ();
1685
- for (const std::string& strAddr : gArgs . GetArgs ( " - connect" ) )
1685
+ for (const std::string& strAddr : connect)
1686
1686
{
1687
1687
CAddress addr (CService (), NODE_NONE);
1688
1688
OpenNetworkConnection (addr, false , NULL , strAddr.c_str ());
@@ -2360,9 +2360,16 @@ bool CConnman::Start(CScheduler& scheduler, Options connOptions)
2360
2360
// Initiate outbound connections from -addnode
2361
2361
threadOpenAddedConnections = std::thread (&TraceThread<std::function<void ()> >, " addcon" , std::function<void ()>(std::bind (&CConnman::ThreadOpenAddedConnections, this )));
2362
2362
2363
- // Initiate outbound connections unless connect=0
2364
- if (!gArgs .IsArgSet (" -connect" ) || gArgs .GetArgs (" -connect" ).size () != 1 || gArgs .GetArgs (" -connect" )[0 ] != " 0" )
2365
- threadOpenConnections = std::thread (&TraceThread<std::function<void ()> >, " opencon" , std::function<void ()>(std::bind (&CConnman::ThreadOpenConnections, this )));
2363
+ if (connOptions.m_use_addrman_outgoing && !connOptions.m_specified_outgoing .empty ()) {
2364
+ if (clientInterface) {
2365
+ clientInterface->ThreadSafeMessageBox (
2366
+ _ (" Cannot provide specific connections and have addrman find outgoing connections at the same." ),
2367
+ " " , CClientUIInterface::MSG_ERROR);
2368
+ }
2369
+ return false ;
2370
+ }
2371
+ if (connOptions.m_use_addrman_outgoing || !connOptions.m_specified_outgoing .empty ())
2372
+ threadOpenConnections = std::thread (&TraceThread<std::function<void ()> >, " opencon" , std::function<void ()>(std::bind (&CConnman::ThreadOpenConnections, this , connOptions.m_specified_outgoing )));
2366
2373
2367
2374
// Process messages
2368
2375
threadMessageHandler = std::thread (&TraceThread<std::function<void ()> >, " msghand" , std::function<void ()>(std::bind (&CConnman::ThreadMessageHandler, this )));
0 commit comments