net: don't import std namespace
This commit is contained in:
59
src/net.cpp
59
src/net.cpp
@@ -56,7 +56,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
const int MAX_OUTBOUND_CONNECTIONS = 8;
|
||||
@@ -77,7 +76,7 @@ bool fListen = true;
|
||||
uint64_t nLocalServices = NODE_NETWORK;
|
||||
bool fRelayTxes = true;
|
||||
CCriticalSection cs_mapLocalHost;
|
||||
map<CNetAddr, LocalServiceInfo> mapLocalHost;
|
||||
std::map<CNetAddr, LocalServiceInfo> mapLocalHost;
|
||||
static bool vfLimited[NET_MAX] = {};
|
||||
static CNode* pnodeLocalHost = NULL;
|
||||
uint64_t nLocalHostNonce = 0;
|
||||
@@ -87,17 +86,17 @@ int nMaxConnections = DEFAULT_MAX_PEER_CONNECTIONS;
|
||||
bool fAddressesInitialized = false;
|
||||
std::string strSubVersion;
|
||||
|
||||
vector<CNode*> vNodes;
|
||||
std::vector<CNode*> vNodes;
|
||||
CCriticalSection cs_vNodes;
|
||||
limitedmap<uint256, int64_t> mapAlreadyAskedFor(MAX_INV_SZ);
|
||||
|
||||
static deque<string> vOneShots;
|
||||
static std::deque<std::string> vOneShots;
|
||||
CCriticalSection cs_vOneShots;
|
||||
|
||||
set<CNetAddr> setservAddNodeAddresses;
|
||||
std::set<CNetAddr> setservAddNodeAddresses;
|
||||
CCriticalSection cs_setservAddNodeAddresses;
|
||||
|
||||
vector<std::string> vAddedNodes;
|
||||
std::vector<std::string> vAddedNodes;
|
||||
CCriticalSection cs_vAddedNodes;
|
||||
|
||||
NodeId nLastNodeId = 0;
|
||||
@@ -131,7 +130,7 @@ bool GetLocal(CService& addr, const CNetAddr *paddrPeer)
|
||||
int nBestReachability = -1;
|
||||
{
|
||||
LOCK(cs_mapLocalHost);
|
||||
for (map<CNetAddr, LocalServiceInfo>::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++)
|
||||
for (std::map<CNetAddr, LocalServiceInfo>::iterator it = mapLocalHost.begin(); it != mapLocalHost.end(); it++)
|
||||
{
|
||||
int nScore = (*it).second.nScore;
|
||||
int nReachability = (*it).first.GetReachabilityFrom(paddrPeer);
|
||||
@@ -789,7 +788,7 @@ void SocketSendData(CNode *pnode)
|
||||
pnode->vSendMsg.erase(pnode->vSendMsg.begin(), it);
|
||||
}
|
||||
|
||||
static list<CNode*> vNodesDisconnected;
|
||||
static std::list<CNode*> vNodesDisconnected;
|
||||
|
||||
class CNodeRef {
|
||||
public:
|
||||
@@ -1038,7 +1037,7 @@ void ThreadSocketHandler()
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
// Disconnect unused nodes
|
||||
vector<CNode*> vNodesCopy = vNodes;
|
||||
std::vector<CNode*> vNodesCopy = vNodes;
|
||||
BOOST_FOREACH(CNode* pnode, vNodesCopy)
|
||||
{
|
||||
if (pnode->fDisconnect ||
|
||||
@@ -1062,7 +1061,7 @@ void ThreadSocketHandler()
|
||||
}
|
||||
{
|
||||
// Delete disconnected nodes
|
||||
list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected;
|
||||
std::list<CNode*> vNodesDisconnectedCopy = vNodesDisconnected;
|
||||
BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy)
|
||||
{
|
||||
// wait until threads are done using it
|
||||
@@ -1113,7 +1112,7 @@ void ThreadSocketHandler()
|
||||
|
||||
BOOST_FOREACH(const ListenSocket& hListenSocket, vhListenSocket) {
|
||||
FD_SET(hListenSocket.socket, &fdsetRecv);
|
||||
hSocketMax = max(hSocketMax, hListenSocket.socket);
|
||||
hSocketMax = std::max(hSocketMax, hListenSocket.socket);
|
||||
have_fds = true;
|
||||
}
|
||||
|
||||
@@ -1124,7 +1123,7 @@ void ThreadSocketHandler()
|
||||
if (pnode->hSocket == INVALID_SOCKET)
|
||||
continue;
|
||||
FD_SET(pnode->hSocket, &fdsetError);
|
||||
hSocketMax = max(hSocketMax, pnode->hSocket);
|
||||
hSocketMax = std::max(hSocketMax, pnode->hSocket);
|
||||
have_fds = true;
|
||||
|
||||
// Implement the following logic:
|
||||
@@ -1191,7 +1190,7 @@ void ThreadSocketHandler()
|
||||
//
|
||||
// Service each socket
|
||||
//
|
||||
vector<CNode*> vNodesCopy;
|
||||
std::vector<CNode*> vNodesCopy;
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
vNodesCopy = vNodes;
|
||||
@@ -1348,7 +1347,7 @@ void ThreadMapPort()
|
||||
}
|
||||
}
|
||||
|
||||
string strDesc = "Bitcoin " + FormatFullVersion();
|
||||
std::string strDesc = "Bitcoin " + FormatFullVersion();
|
||||
|
||||
try {
|
||||
while (true) {
|
||||
@@ -1434,7 +1433,7 @@ void ThreadDNSAddressSeed()
|
||||
}
|
||||
}
|
||||
|
||||
const vector<CDNSSeedData> &vSeeds = Params().DNSSeeds();
|
||||
const std::vector<CDNSSeedData> &vSeeds = Params().DNSSeeds();
|
||||
int found = 0;
|
||||
|
||||
LogPrintf("Loading addresses from DNS seeds (could take a while)\n");
|
||||
@@ -1443,8 +1442,8 @@ void ThreadDNSAddressSeed()
|
||||
if (HaveNameProxy()) {
|
||||
AddOneShot(seed.host);
|
||||
} else {
|
||||
vector<CNetAddr> vIPs;
|
||||
vector<CAddress> vAdd;
|
||||
std::vector<CNetAddr> vIPs;
|
||||
std::vector<CAddress> vAdd;
|
||||
if (LookupHost(seed.host.c_str(), vIPs, 0, true))
|
||||
{
|
||||
BOOST_FOREACH(const CNetAddr& ip, vIPs)
|
||||
@@ -1506,7 +1505,7 @@ void DumpData()
|
||||
|
||||
void static ProcessOneShot()
|
||||
{
|
||||
string strDest;
|
||||
std::string strDest;
|
||||
{
|
||||
LOCK(cs_vOneShots);
|
||||
if (vOneShots.empty())
|
||||
@@ -1572,7 +1571,7 @@ void ThreadOpenConnections()
|
||||
// Only connect out to one peer per network group (/16 for IPv4).
|
||||
// Do this here so we don't have to critsect vNodes inside mapAddresses critsect.
|
||||
int nOutbound = 0;
|
||||
set<vector<unsigned char> > setConnected;
|
||||
std::set<std::vector<unsigned char> > setConnected;
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
BOOST_FOREACH(CNode* pnode, vNodes) {
|
||||
@@ -1630,7 +1629,7 @@ void ThreadOpenAddedConnections()
|
||||
|
||||
if (HaveNameProxy()) {
|
||||
while(true) {
|
||||
list<string> lAddresses(0);
|
||||
std::list<std::string> lAddresses(0);
|
||||
{
|
||||
LOCK(cs_vAddedNodes);
|
||||
BOOST_FOREACH(const std::string& strAddNode, vAddedNodes)
|
||||
@@ -1648,16 +1647,16 @@ void ThreadOpenAddedConnections()
|
||||
|
||||
for (unsigned int i = 0; true; i++)
|
||||
{
|
||||
list<string> lAddresses(0);
|
||||
std::list<std::string> lAddresses(0);
|
||||
{
|
||||
LOCK(cs_vAddedNodes);
|
||||
BOOST_FOREACH(const std::string& strAddNode, vAddedNodes)
|
||||
lAddresses.push_back(strAddNode);
|
||||
}
|
||||
|
||||
list<vector<CService> > lservAddressesToAdd(0);
|
||||
std::list<std::vector<CService> > lservAddressesToAdd(0);
|
||||
BOOST_FOREACH(const std::string& strAddNode, lAddresses) {
|
||||
vector<CService> vservNode(0);
|
||||
std::vector<CService> vservNode(0);
|
||||
if(Lookup(strAddNode.c_str(), vservNode, Params().GetDefaultPort(), fNameLookup, 0))
|
||||
{
|
||||
lservAddressesToAdd.push_back(vservNode);
|
||||
@@ -1673,7 +1672,7 @@ void ThreadOpenAddedConnections()
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
BOOST_FOREACH(CNode* pnode, vNodes)
|
||||
for (list<vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++)
|
||||
for (std::list<std::vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++)
|
||||
BOOST_FOREACH(const CService& addrNode, *(it))
|
||||
if (pnode->addr == addrNode)
|
||||
{
|
||||
@@ -1682,7 +1681,7 @@ void ThreadOpenAddedConnections()
|
||||
break;
|
||||
}
|
||||
}
|
||||
BOOST_FOREACH(vector<CService>& vserv, lservAddressesToAdd)
|
||||
BOOST_FOREACH(std::vector<CService>& vserv, lservAddressesToAdd)
|
||||
{
|
||||
CSemaphoreGrant grant(*semOutbound);
|
||||
OpenNetworkConnection(CAddress(vserv[i % vserv.size()]), &grant);
|
||||
@@ -1730,7 +1729,7 @@ void ThreadMessageHandler()
|
||||
SetThreadPriority(THREAD_PRIORITY_BELOW_NORMAL);
|
||||
while (true)
|
||||
{
|
||||
vector<CNode*> vNodesCopy;
|
||||
std::vector<CNode*> vNodesCopy;
|
||||
{
|
||||
LOCK(cs_vNodes);
|
||||
vNodesCopy = vNodes;
|
||||
@@ -1790,7 +1789,7 @@ void ThreadMessageHandler()
|
||||
|
||||
|
||||
|
||||
bool BindListenPort(const CService &addrBind, string& strError, bool fWhitelisted)
|
||||
bool BindListenPort(const CService &addrBind, std::string& strError, bool fWhitelisted)
|
||||
{
|
||||
strError = "";
|
||||
int nOne = 1;
|
||||
@@ -1898,7 +1897,7 @@ void static Discover(boost::thread_group& threadGroup)
|
||||
char pszHostName[256] = "";
|
||||
if (gethostname(pszHostName, sizeof(pszHostName)) != SOCKET_ERROR)
|
||||
{
|
||||
vector<CNetAddr> vaddr;
|
||||
std::vector<CNetAddr> vaddr;
|
||||
if (LookupHost(pszHostName, vaddr, 0, true))
|
||||
{
|
||||
BOOST_FOREACH (const CNetAddr &addr, vaddr)
|
||||
@@ -2281,7 +2280,7 @@ bool CAddrDB::Read(CAddrMan& addr)
|
||||
// Don't try to resize to a negative number if file is small
|
||||
if (fileSize >= sizeof(uint256))
|
||||
dataSize = fileSize - sizeof(uint256);
|
||||
vector<unsigned char> vchData;
|
||||
std::vector<unsigned char> vchData;
|
||||
vchData.resize(dataSize);
|
||||
uint256 hashIn;
|
||||
|
||||
@@ -2562,7 +2561,7 @@ bool CBanDB::Read(banmap_t& banSet)
|
||||
// Don't try to resize to a negative number if file is small
|
||||
if (fileSize >= sizeof(uint256))
|
||||
dataSize = fileSize - sizeof(uint256);
|
||||
vector<unsigned char> vchData;
|
||||
std::vector<unsigned char> vchData;
|
||||
vchData.resize(dataSize);
|
||||
uint256 hashIn;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user