mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Add network traffic graph
This commit is contained in:
parent
9269d0e96e
commit
ce14345a89
13 changed files with 618 additions and 9 deletions
37
src/net.cpp
37
src/net.cpp
|
|
@ -426,8 +426,10 @@ void AddressCurrentlyConnected(const CService& addr)
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
uint64 CNode::nTotalBytesRecv = 0;
|
||||
uint64 CNode::nTotalBytesSent = 0;
|
||||
CCriticalSection CNode::cs_totalBytesRecv;
|
||||
CCriticalSection CNode::cs_totalBytesSent;
|
||||
|
||||
CNode* FindNode(const CNetAddr& ip)
|
||||
{
|
||||
|
|
@ -731,6 +733,7 @@ void SocketSendData(CNode *pnode)
|
|||
pnode->nLastSend = GetTime();
|
||||
pnode->nSendBytes += nBytes;
|
||||
pnode->nSendOffset += nBytes;
|
||||
pnode->RecordBytesSent(nBytes);
|
||||
if (pnode->nSendOffset == data.size()) {
|
||||
pnode->nSendOffset = 0;
|
||||
pnode->nSendSize -= data.size();
|
||||
|
|
@ -826,10 +829,9 @@ void ThreadSocketHandler()
|
|||
}
|
||||
}
|
||||
}
|
||||
if (vNodes.size() != nPrevNodeCount)
|
||||
{
|
||||
if(vNodes.size() != nPrevNodeCount) {
|
||||
nPrevNodeCount = vNodes.size();
|
||||
uiInterface.NotifyNumConnectionsChanged(vNodes.size());
|
||||
uiInterface.NotifyNumConnectionsChanged(nPrevNodeCount);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1008,6 +1010,7 @@ void ThreadSocketHandler()
|
|||
pnode->CloseSocketDisconnect();
|
||||
pnode->nLastRecv = GetTime();
|
||||
pnode->nRecvBytes += nBytes;
|
||||
pnode->RecordBytesRecv(nBytes);
|
||||
}
|
||||
else if (nBytes == 0)
|
||||
{
|
||||
|
|
@ -1859,3 +1862,27 @@ void RelayTransaction(const CTransaction& tx, const uint256& hash, const CDataSt
|
|||
pnode->PushInventory(inv);
|
||||
}
|
||||
}
|
||||
|
||||
void CNode::RecordBytesRecv(uint64 bytes)
|
||||
{
|
||||
LOCK(cs_totalBytesRecv);
|
||||
nTotalBytesRecv += bytes;
|
||||
}
|
||||
|
||||
void CNode::RecordBytesSent(uint64 bytes)
|
||||
{
|
||||
LOCK(cs_totalBytesSent);
|
||||
nTotalBytesSent += bytes;
|
||||
}
|
||||
|
||||
uint64 CNode::GetTotalBytesRecv()
|
||||
{
|
||||
LOCK(cs_totalBytesRecv);
|
||||
return nTotalBytesRecv;
|
||||
}
|
||||
|
||||
uint64 CNode::GetTotalBytesSent()
|
||||
{
|
||||
LOCK(cs_totalBytesSent);
|
||||
return nTotalBytesSent;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue