|
|
@ -313,12 +313,6 @@ bool IsReachable(const CNetAddr& addr) |
|
|
|
return IsReachable(net); |
|
|
|
return IsReachable(net); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void AddressCurrentlyConnected(const CService& addr) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
addrman.Connected(addr); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint64_t CNode::nTotalBytesRecv = 0; |
|
|
|
uint64_t CNode::nTotalBytesRecv = 0; |
|
|
|
uint64_t CNode::nTotalBytesSent = 0; |
|
|
|
uint64_t CNode::nTotalBytesSent = 0; |
|
|
|
CCriticalSection CNode::cs_totalBytesRecv; |
|
|
|
CCriticalSection CNode::cs_totalBytesRecv; |
|
|
@ -431,6 +425,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo |
|
|
|
|
|
|
|
|
|
|
|
// Add node
|
|
|
|
// Add node
|
|
|
|
CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false); |
|
|
|
CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false); |
|
|
|
|
|
|
|
GetNodeSignals().InitializeNode(pnode->GetId(), pnode); |
|
|
|
pnode->AddRef(); |
|
|
|
pnode->AddRef(); |
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
@ -1070,6 +1065,7 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CNode* pnode = new CNode(hSocket, addr, "", true); |
|
|
|
CNode* pnode = new CNode(hSocket, addr, "", true); |
|
|
|
|
|
|
|
GetNodeSignals().InitializeNode(pnode->GetId(), pnode); |
|
|
|
pnode->AddRef(); |
|
|
|
pnode->AddRef(); |
|
|
|
pnode->fWhitelisted = whitelisted; |
|
|
|
pnode->fWhitelisted = whitelisted; |
|
|
|
|
|
|
|
|
|
|
@ -1139,7 +1135,7 @@ void CConnman::ThreadSocketHandler() |
|
|
|
if (fDelete) |
|
|
|
if (fDelete) |
|
|
|
{ |
|
|
|
{ |
|
|
|
vNodesDisconnected.remove(pnode); |
|
|
|
vNodesDisconnected.remove(pnode); |
|
|
|
delete pnode; |
|
|
|
DeleteNode(pnode); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2119,6 +2115,7 @@ bool CConnman::Start(boost::thread_group& threadGroup, std::string& strNodeError |
|
|
|
CNetAddr local; |
|
|
|
CNetAddr local; |
|
|
|
LookupHost("127.0.0.1", local, false); |
|
|
|
LookupHost("127.0.0.1", local, false); |
|
|
|
pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService(local, 0), nLocalServices)); |
|
|
|
pnodeLocalHost = new CNode(INVALID_SOCKET, CAddress(CService(local, 0), nLocalServices)); |
|
|
|
|
|
|
|
GetNodeSignals().InitializeNode(pnodeLocalHost->GetId(), pnodeLocalHost); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -2194,19 +2191,32 @@ void CConnman::Stop() |
|
|
|
LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError())); |
|
|
|
LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError())); |
|
|
|
|
|
|
|
|
|
|
|
// clean up some globals (to help leak detection)
|
|
|
|
// clean up some globals (to help leak detection)
|
|
|
|
BOOST_FOREACH(CNode *pnode, vNodes) |
|
|
|
BOOST_FOREACH(CNode *pnode, vNodes) { |
|
|
|
delete pnode; |
|
|
|
DeleteNode(pnode); |
|
|
|
BOOST_FOREACH(CNode *pnode, vNodesDisconnected) |
|
|
|
} |
|
|
|
delete pnode; |
|
|
|
BOOST_FOREACH(CNode *pnode, vNodesDisconnected) { |
|
|
|
|
|
|
|
DeleteNode(pnode); |
|
|
|
|
|
|
|
} |
|
|
|
vNodes.clear(); |
|
|
|
vNodes.clear(); |
|
|
|
vNodesDisconnected.clear(); |
|
|
|
vNodesDisconnected.clear(); |
|
|
|
vhListenSocket.clear(); |
|
|
|
vhListenSocket.clear(); |
|
|
|
delete semOutbound; |
|
|
|
delete semOutbound; |
|
|
|
semOutbound = NULL; |
|
|
|
semOutbound = NULL; |
|
|
|
delete pnodeLocalHost; |
|
|
|
if(pnodeLocalHost) |
|
|
|
|
|
|
|
DeleteNode(pnodeLocalHost); |
|
|
|
pnodeLocalHost = NULL; |
|
|
|
pnodeLocalHost = NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CConnman::DeleteNode(CNode* pnode) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
assert(pnode); |
|
|
|
|
|
|
|
bool fUpdateConnectionTime = false; |
|
|
|
|
|
|
|
GetNodeSignals().FinalizeNode(pnode->GetId(), fUpdateConnectionTime); |
|
|
|
|
|
|
|
if(fUpdateConnectionTime) |
|
|
|
|
|
|
|
addrman.Connected(pnode->addr); |
|
|
|
|
|
|
|
delete pnode; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CConnman::~CConnman() |
|
|
|
CConnman::~CConnman() |
|
|
|
{ |
|
|
|
{ |
|
|
|
} |
|
|
|
} |
|
|
@ -2442,8 +2452,6 @@ CNode::CNode(SOCKET hSocketIn, const CAddress& addrIn, const std::string& addrNa |
|
|
|
// Be shy and don't send version until we hear
|
|
|
|
// Be shy and don't send version until we hear
|
|
|
|
if (hSocket != INVALID_SOCKET && !fInbound) |
|
|
|
if (hSocket != INVALID_SOCKET && !fInbound) |
|
|
|
PushVersion(); |
|
|
|
PushVersion(); |
|
|
|
|
|
|
|
|
|
|
|
GetNodeSignals().InitializeNode(GetId(), this); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
CNode::~CNode() |
|
|
|
CNode::~CNode() |
|
|
@ -2452,8 +2460,6 @@ CNode::~CNode() |
|
|
|
|
|
|
|
|
|
|
|
if (pfilter) |
|
|
|
if (pfilter) |
|
|
|
delete pfilter; |
|
|
|
delete pfilter; |
|
|
|
|
|
|
|
|
|
|
|
GetNodeSignals().FinalizeNode(GetId()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void CNode::AskFor(const CInv& inv) |
|
|
|
void CNode::AskFor(const CInv& inv) |
|
|
|