Skip to content

Commit

Permalink
prevent nodes that refuse to roll back from spamming
Browse files Browse the repository at this point in the history
  • Loading branch information
hclivess committed Sep 19, 2019
1 parent 087dd15 commit f2bc8a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions node.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,10 @@ def handle(self):
send(self.request, "blocknfhb") # announce we are on hyperblocks
send(self.request, data)

if node.peers.warning(self.request, peer_ip, "Forked", 2):
node.logger.app_log.info(f"{peer_ip} banned")
break

else:
node.logger.app_log.info(f"Inbound: Client is at block {client_block}") # now check if we have any newer

Expand Down
3 changes: 3 additions & 0 deletions worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ def worker(host, port, node):
send(s, "blocknfhb")
send(s, data)

if node.peers.warning(s, peer_ip, "Forked", 1):
raise ValueError(f"{peer_ip} is banned")

else:
node.logger.app_log.warning(
f"Outbound: Node is at block {client_block}") # now check if we have any newer
Expand Down

0 comments on commit f2bc8a5

Please sign in to comment.