MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / SendRejectsAndCheckIfBanned

Function SendRejectsAndCheckIfBanned

src/net_processing.cpp:2962–2992  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2960}
2961
2962static bool SendRejectsAndCheckIfBanned(CNode* pnode, CConnman* connman, bool enable_bip61)
2963{
2964 AssertLockHeld(cs_main);
2965 CNodeState &state = *State(pnode->GetId());
2966
2967 if (enable_bip61) {
2968 for (const CBlockReject& reject : state.rejects) {
2969 connman->PushMessage(pnode, CNetMsgMaker(INIT_PROTO_VERSION).Make(NetMsgType::REJECT, std::string(NetMsgType::BLOCK), reject.chRejectCode, reject.strRejectReason, reject.hashBlock));
2970 }
2971 }
2972 state.rejects.clear();
2973
2974 if (state.fShouldBan) {
2975 state.fShouldBan = false;
2976 if (pnode->fWhitelisted)
2977 LogPrintf("Warning: not punishing whitelisted peer %s!\n", pnode->addr.ToString());
2978 else if (pnode->m_manual_connection)
2979 LogPrintf("Warning: not punishing manually-connected peer %s!\n", pnode->addr.ToString());
2980 else {
2981 pnode->fDisconnect = true;
2982 if (pnode->addr.IsLocal())
2983 LogPrintf("Warning: not banning local peer %s!\n", pnode->addr.ToString());
2984 else
2985 {
2986 connman->Ban(pnode->addr, BanReasonNodeMisbehaving);
2987 }
2988 }
2989 return true;
2990 }
2991 return false;
2992}
2993
2994bool PeerLogicValidation::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgProc)
2995{

Callers 2

ProcessMessagesMethod · 0.85
SendMessagesMethod · 0.85

Calls 9

CNetMsgMakerClass · 0.85
GetIdMethod · 0.80
PushMessageMethod · 0.80
MakeMethod · 0.80
IsLocalMethod · 0.80
BanMethod · 0.80
StateClass · 0.50
clearMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected