aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-11-18 01:25:17 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2013-12-08 14:51:37 +0100
commitb2864d2fb35fa85e32c76e111f8900598e0bb69d (patch)
treee34d33bf5a9309ce4e60ba1e1889a5bf1b6c7beb /src/net.cpp
parent70370ae502df8756f3a067a00ccd61b9fc819581 (diff)
Add main-specific node state
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp32
1 files changed, 10 insertions, 22 deletions
diff --git a/src/net.cpp b/src/net.cpp
index afffbdf1da..a6a04cdd46 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -80,6 +80,9 @@ CCriticalSection cs_setservAddNodeAddresses;
vector<std::string> vAddedNodes;
CCriticalSection cs_vAddedNodes;
+NodeId nLastNodeId = 0;
+CCriticalSection cs_nLastNodeId;
+
static CSemaphore *semOutbound = NULL;
// Signals for message handling
@@ -581,35 +584,21 @@ bool CNode::IsBanned(CNetAddr ip)
return fResult;
}
-bool CNode::Misbehaving(int howmuch)
-{
- if (addr.IsLocal())
+bool CNode::Ban(const CNetAddr &addr) {
+ int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
{
- LogPrintf("Warning: Local node %s misbehaving (delta: %d)!\n", addrName.c_str(), howmuch);
- return false;
+ LOCK(cs_setBanned);
+ if (setBanned[addr] < banTime)
+ setBanned[addr] = banTime;
}
-
- nMisbehavior += howmuch;
- if (nMisbehavior >= GetArg("-banscore", 100))
- {
- int64_t banTime = GetTime()+GetArg("-bantime", 60*60*24); // Default 24-hour ban
- LogPrintf("Misbehaving: %s (%d -> %d) DISCONNECTING\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
- {
- LOCK(cs_setBanned);
- if (setBanned[addr] < banTime)
- setBanned[addr] = banTime;
- }
- CloseSocketDisconnect();
- return true;
- } else
- LogPrintf("Misbehaving: %s (%d -> %d)\n", addr.ToString().c_str(), nMisbehavior-howmuch, nMisbehavior);
- return false;
+ return true;
}
#undef X
#define X(name) stats.name = name
void CNode::copyStats(CNodeStats &stats)
{
+ stats.nodeid = this->GetId();
X(nServices);
X(nLastSend);
X(nLastRecv);
@@ -619,7 +608,6 @@ void CNode::copyStats(CNodeStats &stats)
X(cleanSubVer);
X(fInbound);
X(nStartingHeight);
- X(nMisbehavior);
X(nSendBytes);
X(nRecvBytes);
stats.fSyncNode = (this == pnodeSync);