I read somewhere that a node is banned for 24 hours.

However I found the Misbehaving() function which makes state->fShouldBan = true;. But I could not find any other function that makes state->fShouldBan = false;. It seems that banning is forever.

If banning is forever, I guess the node also removes the misbehaving peer from its neighbor list, right? But I could not find it.

  • What do you mean by 'neighbor list'? May 30, 2017 at 16:58
  • Nodes are not keeping a list of neighbors to get data from? May 30, 2017 at 22:59
  • Bitcoin Core maintains a database of possible IP addresses of nodes to consider connecting to, called addrman. I was just confused by your usage of the term 'neighbor'. May 31, 2017 at 0:18

2 Answers 2


When state->fShouldBan is set, the network thread will disconnect the node, and cleanup memory. As a result, the state object disappears entirely. Because of that, there is no need to ever unset fShouldBan.

What does happen is that when the actual ban happens (not just the setting of the fShouldBan field), it is added to the ban table (which is IP based). Entries in this table have an expiration time. The default expiration time for newly banned nodes is controlled by the -bantime option and defaults to 24 hours in the future.

  • So as I understand the state object is created when a node receives a message from another node, right? And if fShouldBan is set to true, this process is cut. On the other hand, I didn't exactly get when the actual ban happens. Isn't it right after fShouldBan=true;? May 31, 2017 at 7:39
  • A second remark about the IP-based banning. Is it really a good idea? A node can easily change its IP address, no? May 31, 2017 at 7:43
  • The actual ban happens elsewhere, see the connman.Ban in SendRejectsAndCheckIfBanned in net_processing.cpp. A node can indeed easily change their IP address, but they do need to reconnect first, and IP addresses do have a non-zero cost. May 31, 2017 at 15:59

Bans last for as many seconds as bantime (in bitcoin.conf) is set to:

-bantime=<n> Number of seconds to keep misbehaving peers from reconnecting (default: 86400)

86400 seconds is 1 day.

  • Can you explain more about banscore? I was thinking that it is a threshold for deciding if a node should be banned or not, not about the time. May 31, 2017 at 7:42
  • @ÖnderGürcan You're right! I've edited my answer.
    – Geremia
    May 31, 2017 at 17:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.