Look closely, do you see there is anything missing in yours?
Thank you, I did miss that part yeah. Here it is:
//! Whether this peer should be disconnected and banned (unless whitelisted).
bool fShouldBan;
Source:
https://github.com/bitcoinxt/bitcoinxt/blob/master/src/main.cppLines: 223 and 224
Just because it isn't in the linked commit, doesn't mean it doesn't exist. It exists in the master branch and the
latest release.
Oooo I missed this. Nice someone took one line out of a context...
Just a part of code in question:
/**
* Maintain validation-specific state about nodes, protected by cs_main, instead
* by CNode's own locks. This simplifies asynchronous operation, where
* processing of incoming data is done after the ProcessMessage call returns,
* and we're no longer holding the node's locks.
*/
struct CNodeState {
//! The peer's address
CService address;
//! Whether we have a fully established connection.
bool fCurrentlyConnected;
//! Accumulated misbehaviour score for this peer.
int nMisbehavior;
//! Whether this peer should be disconnected and banned (unless whitelisted).
bool fShouldBan;
//! String name of this peer (debugging/logging purposes).
std::string name;
//! List of asynchronously-determined block rejections to notify this peer about.
std::vector rejects;
//! The best known block we know this peer has announced.
CBlockIndex *pindexBestKnownBlock;
//! The hash of the last unknown block this peer has announced.
uint256 hashLastUnknownBlock;
//! The last full block we both have.
CBlockIndex *pindexLastCommonBlock;
//! Whether we've started headers synchronization with this peer.
bool fSyncStarted;
//! Since when we're stalling block download progress (in microseconds), or 0.
int64_t nStallingSince;
list vBlocksInFlight;
int nBlocksInFlight;
int nBlocksInFlightValidHeaders;
//! Whether we consider this a preferred download peer.
bool fPreferredDownload;
CNodeState() {
fCurrentlyConnected = false;
nMisbehavior = 0;
fShouldBan = false;
pindexBestKnownBlock = NULL;
hashLastUnknownBlock.SetNull();
pindexLastCommonBlock = NULL;
fSyncStarted = false;
nStallingSince = 0;
nBlocksInFlight = 0;
nBlocksInFlightValidHeaders = 0;
fPreferredDownload = false;
}
};
void Misbehaving(NodeId pnode, int howmuch)
{
if (howmuch == 0)
return;
NodeStatePtr state(pnode);
if (state.IsNull())
return;
state->nMisbehavior += howmuch;
int banscore = GetArg("-banscore", 100);
if (state->nMisbehavior >= banscore && state->nMisbehavior - howmuch < banscore)
{
LogPrintf("%s: %s (%d -> %d) BAN THRESHOLD EXCEEDED\n", __func__, state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
state->fShouldBan = true;
} else
LogPrintf("%s: %s (%d -> %d)\n", __func__, state->name, state->nMisbehavior-howmuch, state->nMisbehavior);
}
void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state) {
int nDoS = 0;
if (state.IsInvalid(nDoS)) {
std::map::iterator it = mapBlockSource.find(pindex->GetBlockHash());
NodeStatePtr nodeState(it->second);
if (it != mapBlockSource.end() && !nodeState.IsNull()) {
CBlockReject reject = {state.GetRejectCode(), state.GetRejectReason().substr(0, MAX_REJECT_MESSAGE_LENGTH), pindex->GetBlockHash()};
nodeState->rejects.push_back(reject);
if (nDoS > 0)
Misbehaving(it->second, nDoS);
}
}
if (!state.CorruptionPossible()) {
pindex->nStatus |= BLOCK_FAILED_VALID;
setDirtyBlockIndex.insert(pindex);
setBlockIndexCandidates.erase(pindex);
InvalidChainFound(pindex);
}
}
bool static SanityCheckMessage(CNode* peer, const CNetMessage& msg)
{
const std::string& strCommand = msg.hdr.GetCommand();
if (strCommand == "block") {
uint64_t maxSize = Params().GetConsensus().MaxBlockSize(GetAdjustedTime() + 2 * 60 * 60, sizeForkTime.load());
if (msg.hdr.nMessageSize > maxSize) {
LogPrint("net", "Oversized %s message from peer=%i\n", SanitizeString(strCommand), peer->GetId());
return false;
}
}
else if (msg.hdr.nMessageSize > MAX_PROTOCOL_MESSAGE_LENGTH ||
(maxMessageSizes.count(strCommand) && msg.hdr.nMessageSize > maxMessageSizes[strCommand])) {
LogPrint("net", "Oversized %s message from peer=%i (%d bytes)\n",
SanitizeString(strCommand), peer->GetId(), msg.hdr.nMessageSize);
Misbehaving(peer->GetId(), 20);
return msg.hdr.nMessageSize <= MAX_PROTOCOL_MESSAGE_LENGTH;
}
// This would be a good place for more sophisticated DoS detection/prevention.
// (e.g. disconnect a peer that is flooding us with excessive messages)
return true;
}
There is much more of the code... More then I can get in this mesage. Just search for Misbehaving
See the diference? There a re a lot of things you need to do to activate this? Something normal node will not do.