Skip to content

Commit

Permalink
Merge bitcoin#10467: add SeedNodes to CConnman::Options
Browse files Browse the repository at this point in the history
5d67526 add SeedNodes to CConnman::Options (Marko Bencun)

Tree-SHA512: d732ab08697419f896d9598fa3c30030ddbe3b82a99a398d813ebcd5e1fc610ad1043fe0f4c51a7ec5c4d70ce93a9ac5a5c7a91fcaae046ec4f1f7c41523a360
  • Loading branch information
laanwj committed May 31, 2017
2 parents 5dd69ce + 5d67526 commit 18ba984
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
9 changes: 4 additions & 5 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1386,11 +1386,6 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
}
}

if (gArgs.IsArgSet("-seednode")) {
BOOST_FOREACH(const std::string& strDest, gArgs.GetArgs("-seednode"))
connman.AddOneShot(strDest);
}

#if ENABLE_ZMQ
pzmqNotificationInterface = CZMQNotificationInterface::Create();

Expand Down Expand Up @@ -1659,6 +1654,10 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
connOptions.nMaxOutboundTimeframe = nMaxOutboundTimeframe;
connOptions.nMaxOutboundLimit = nMaxOutboundLimit;

if (gArgs.IsArgSet("-seednode")) {
connOptions.vSeedNodes = gArgs.GetArgs("-seednode");
}

if (!connman.Start(scheduler, strNodeError, connOptions))
return InitError(strNodeError);

Expand Down
8 changes: 6 additions & 2 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1743,9 +1743,9 @@ void CConnman::ThreadOpenConnections()
// * Increase the number of connectable addresses in the tried table.
//
// Method:
// * Choose a random address from new and attempt to connect to it if we can connect
// * Choose a random address from new and attempt to connect to it if we can connect
// successfully it is added to tried.
// * Start attempting feeler connections only after node finishes making outbound
// * Start attempting feeler connections only after node finishes making outbound
// connections.
// * Only make a feeler connection once every few minutes.
//
Expand Down Expand Up @@ -2212,6 +2212,10 @@ bool CConnman::Start(CScheduler& scheduler, std::string& strNodeError, Options c

SetBestHeight(connOptions.nBestHeight);

for (const auto& strDest : connOptions.vSeedNodes) {
AddOneShot(strDest);
}

clientInterface = connOptions.uiInterface;
if (clientInterface) {
clientInterface->InitMessage(_("Loading P2P addresses..."));
Expand Down
4 changes: 2 additions & 2 deletions src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class CConnman
unsigned int nReceiveFloodSize = 0;
uint64_t nMaxOutboundTimeframe = 0;
uint64_t nMaxOutboundLimit = 0;
std::vector<std::string> vSeedNodes;
};
CConnman(uint64_t seed0, uint64_t seed1);
~CConnman();
Expand Down Expand Up @@ -233,8 +234,6 @@ class CConnman
void GetBanned(banmap_t &banmap);
void SetBanned(const banmap_t &banmap);

void AddOneShot(const std::string& strDest);

bool AddNode(const std::string& node);
bool RemoveAddedNode(const std::string& node);
std::vector<AddedNodeInfo> GetAddedNodeInfo();
Expand Down Expand Up @@ -292,6 +291,7 @@ class CConnman
};

void ThreadOpenAddedConnections();
void AddOneShot(const std::string& strDest);
void ProcessOneShot();
void ThreadOpenConnections();
void ThreadMessageHandler();
Expand Down

0 comments on commit 18ba984

Please sign in to comment.