diff options
| author | Cory Fields <[email protected]> | 2016-04-16 18:12:58 -0400 |
|---|---|---|
| committer | Cory Fields <[email protected]> | 2016-09-08 12:12:58 -0400 |
| commit | 8ae2dac1c65349e4620422a43b7fa9d49af52c11 (patch) | |
| tree | 01bce145e22f6b1319fe9b68eb71f1af05962f00 /src/net.cpp | |
| parent | net: Add oneshot functions to CConnman (diff) | |
| download | discoin-8ae2dac1c65349e4620422a43b7fa9d49af52c11.tar.xz discoin-8ae2dac1c65349e4620422a43b7fa9d49af52c11.zip | |
net: move added node functions to CConnman
Diffstat (limited to 'src/net.cpp')
| -rw-r--r-- | src/net.cpp | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp index 045939c2e..8ca6df0f9 100644 --- a/src/net.cpp +++ b/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()); |