Move NotifyNumConnectionsChanged logic to private method.
This commit is contained in:
parent
2f7ae35ce8
commit
edb5350c32
2 changed files with 18 additions and 11 deletions
27
src/net.cpp
27
src/net.cpp
|
@ -1153,9 +1153,22 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CConnman::NotifyNumConnectionsChanged()
|
||||||
|
{
|
||||||
|
size_t vNodesSize;
|
||||||
|
{
|
||||||
|
LOCK(cs_vNodes);
|
||||||
|
vNodesSize = vNodes.size();
|
||||||
|
}
|
||||||
|
if(vNodesSize != nPrevNodeCount) {
|
||||||
|
nPrevNodeCount = vNodesSize;
|
||||||
|
if(clientInterface)
|
||||||
|
clientInterface->NotifyNumConnectionsChanged(vNodesSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CConnman::ThreadSocketHandler()
|
void CConnman::ThreadSocketHandler()
|
||||||
{
|
{
|
||||||
unsigned int nPrevNodeCount = 0;
|
|
||||||
while (!interruptNet)
|
while (!interruptNet)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
@ -1219,16 +1232,7 @@ void CConnman::ThreadSocketHandler()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size_t vNodesSize;
|
NotifyNumConnectionsChanged();
|
||||||
{
|
|
||||||
LOCK(cs_vNodes);
|
|
||||||
vNodesSize = vNodes.size();
|
|
||||||
}
|
|
||||||
if(vNodesSize != nPrevNodeCount) {
|
|
||||||
nPrevNodeCount = vNodesSize;
|
|
||||||
if(clientInterface)
|
|
||||||
clientInterface->NotifyNumConnectionsChanged(vNodesSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Find which sockets have data to receive
|
// Find which sockets have data to receive
|
||||||
|
@ -2217,6 +2221,7 @@ CConnman::CConnman(uint64_t nSeed0In, uint64_t nSeed1In) : nSeed0(nSeed0In), nSe
|
||||||
setBannedIsDirty = false;
|
setBannedIsDirty = false;
|
||||||
fAddressesInitialized = false;
|
fAddressesInitialized = false;
|
||||||
nLastNodeId = 0;
|
nLastNodeId = 0;
|
||||||
|
nPrevNodeCount = 0;
|
||||||
nSendBufferMaxSize = 0;
|
nSendBufferMaxSize = 0;
|
||||||
nReceiveFloodSize = 0;
|
nReceiveFloodSize = 0;
|
||||||
flagInterruptMsgProc = false;
|
flagInterruptMsgProc = false;
|
||||||
|
|
|
@ -336,6 +336,7 @@ private:
|
||||||
void ThreadOpenConnections(std::vector<std::string> connect);
|
void ThreadOpenConnections(std::vector<std::string> connect);
|
||||||
void ThreadMessageHandler();
|
void ThreadMessageHandler();
|
||||||
void AcceptConnection(const ListenSocket& hListenSocket);
|
void AcceptConnection(const ListenSocket& hListenSocket);
|
||||||
|
void NotifyNumConnectionsChanged();
|
||||||
void ThreadSocketHandler();
|
void ThreadSocketHandler();
|
||||||
void ThreadDNSAddressSeed();
|
void ThreadDNSAddressSeed();
|
||||||
|
|
||||||
|
@ -406,6 +407,7 @@ private:
|
||||||
std::list<CNode*> vNodesDisconnected;
|
std::list<CNode*> vNodesDisconnected;
|
||||||
mutable CCriticalSection cs_vNodes;
|
mutable CCriticalSection cs_vNodes;
|
||||||
std::atomic<NodeId> nLastNodeId;
|
std::atomic<NodeId> nLastNodeId;
|
||||||
|
unsigned int nPrevNodeCount;
|
||||||
|
|
||||||
/** Services this instance offers */
|
/** Services this instance offers */
|
||||||
ServiceFlags nLocalServices;
|
ServiceFlags nLocalServices;
|
||||||
|
|
Loading…
Add table
Reference in a new issue