net: move added node functions to CConnman

This commit is contained in:
Cory Fields
2016-04-16 18:12:58 -04:00
parent 502dd3a8a0
commit 8ae2dac1c6
3 changed files with 46 additions and 28 deletions

View File

@@ -91,9 +91,6 @@ std::vector<CNode*> vNodes;
CCriticalSection cs_vNodes;
limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
std::vector<std::string> vAddedNodes;
CCriticalSection cs_vAddedNodes;
NodeId nLastNodeId = 0;
CCriticalSection cs_nLastNodeId;
@@ -1718,7 +1715,7 @@ void CConnman::ThreadOpenConnections()
}
}
std::vector<AddedNodeInfo> GetAddedNodeInfo()
std::vector<AddedNodeInfo> CConnman::GetAddedNodeInfo()
{
std::vector<AddedNodeInfo> ret;
@@ -2246,6 +2243,30 @@ std::vector<CAddress> CConnman::GetAddresses()
return addrman.GetAddr();
}
bool CConnman::AddNode(const std::string& strNode)
{
LOCK(cs_vAddedNodes);
for(std::vector<std::string>::const_iterator it = vAddedNodes.begin(); it != vAddedNodes.end(); ++it) {
if (strNode == *it)
return false;
}
vAddedNodes.push_back(strNode);
return true;
}
bool CConnman::RemoveAddedNode(const std::string& strNode)
{
LOCK(cs_vAddedNodes);
for(std::vector<std::string>::iterator it = vAddedNodes.begin(); it != vAddedNodes.end(); ++it) {
if (strNode == *it) {
vAddedNodes.erase(it);
return true;
}
}
return false;
}
void RelayTransaction(const CTransaction& tx)
{
CInv inv(MSG_TX, tx.GetHash());