mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
net: move added node functions to CConnman
This commit is contained in:
29
src/net.cpp
29
src/net.cpp
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user