2

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.

Önder Gürcan
  • 337
  • 1
  • 8

2 Answers2

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.

Pieter Wuille
  • 105,497
  • 9
  • 194
  • 308
  • 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;? – Önder Gürcan May 31 '17 at 07:39
  • A second remark about the IP-based banning. Is it really a good idea? A node can easily change its IP address, no? – Önder Gürcan May 31 '17 at 07: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. – Pieter Wuille May 31 '17 at 15:59
0

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.

Geremia
  • 4,626
  • 5
  • 38
  • 75