|
|
@ -307,9 +307,11 @@ CNode* CConnman::FindNode(const CSubNet& subNet)
|
|
|
|
CNode* CConnman::FindNode(const std::string& addrName)
|
|
|
|
CNode* CConnman::FindNode(const std::string& addrName)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK(cs_vNodes);
|
|
|
|
LOCK(cs_vNodes);
|
|
|
|
BOOST_FOREACH(CNode* pnode, vNodes)
|
|
|
|
BOOST_FOREACH(CNode* pnode, vNodes) {
|
|
|
|
if (pnode->addrName == addrName)
|
|
|
|
if (pnode->GetAddrName() == addrName) {
|
|
|
|
return (pnode);
|
|
|
|
return (pnode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -373,9 +375,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
|
|
|
CNode* pnode = FindNode((CService)addrConnect);
|
|
|
|
CNode* pnode = FindNode((CService)addrConnect);
|
|
|
|
if (pnode)
|
|
|
|
if (pnode)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (pnode->addrName.empty()) {
|
|
|
|
pnode->MaybeSetAddrName(std::string(pszDest));
|
|
|
|
pnode->addrName = std::string(pszDest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CloseSocket(hSocket);
|
|
|
|
CloseSocket(hSocket);
|
|
|
|
LogPrintf("Failed to open new connection, already connected\n");
|
|
|
|
LogPrintf("Failed to open new connection, already connected\n");
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
@ -593,6 +593,19 @@ void CConnman::AddWhitelistedRange(const CSubNet &subnet) {
|
|
|
|
vWhitelistedRange.push_back(subnet);
|
|
|
|
vWhitelistedRange.push_back(subnet);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string CNode::GetAddrName() const {
|
|
|
|
|
|
|
|
LOCK(cs_addrName);
|
|
|
|
|
|
|
|
return addrName;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CNode::MaybeSetAddrName(const std::string& addrNameIn) {
|
|
|
|
|
|
|
|
LOCK(cs_addrName);
|
|
|
|
|
|
|
|
if (addrName.empty()) {
|
|
|
|
|
|
|
|
addrName = addrNameIn;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#undef X
|
|
|
|
#undef X
|
|
|
|
#define X(name) stats.name = name
|
|
|
|
#define X(name) stats.name = name
|
|
|
|
void CNode::copyStats(CNodeStats &stats)
|
|
|
|
void CNode::copyStats(CNodeStats &stats)
|
|
|
@ -608,7 +621,7 @@ void CNode::copyStats(CNodeStats &stats)
|
|
|
|
X(nLastRecv);
|
|
|
|
X(nLastRecv);
|
|
|
|
X(nTimeConnected);
|
|
|
|
X(nTimeConnected);
|
|
|
|
X(nTimeOffset);
|
|
|
|
X(nTimeOffset);
|
|
|
|
X(addrName);
|
|
|
|
stats.addrName = GetAddrName();
|
|
|
|
X(nVersion);
|
|
|
|
X(nVersion);
|
|
|
|
{
|
|
|
|
{
|
|
|
|
LOCK(cs_SubVer);
|
|
|
|
LOCK(cs_SubVer);
|
|
|
@ -1798,8 +1811,9 @@ std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo()
|
|
|
|
if (pnode->addr.IsValid()) {
|
|
|
|
if (pnode->addr.IsValid()) {
|
|
|
|
mapConnected[pnode->addr] = pnode->fInbound;
|
|
|
|
mapConnected[pnode->addr] = pnode->fInbound;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pnode->addrName.empty()) {
|
|
|
|
std::string addrName = pnode->GetAddrName();
|
|
|
|
mapConnectedByName[pnode->addrName] = std::make_pair(pnode->fInbound, static_cast<const CService&>(pnode->addr));
|
|
|
|
if (!addrName.empty()) {
|
|
|
|
|
|
|
|
mapConnectedByName[std::move(addrName)] = std::make_pair(pnode->fInbound, static_cast<const CService&>(pnode->addr));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|