Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions hathor/conf/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ def MAXIMUM_NUMBER_OF_HALVINGS(self) -> int:
# that the peer is synced (in seconds).
P2P_SYNC_THRESHOLD: int = 60

# Whether to warn the other peer of the reason for closing the connection
WHITELIST_WARN_BLOCKED_PEERS: bool = False

# Maximum number of opened threads that are solving POW for send tokens
MAX_POW_THREADS: int = 5

Expand Down
5 changes: 4 additions & 1 deletion hathor/p2p/states/peer_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,10 @@ def handle_peer_id(self, payload: str) -> Generator[Any, Any, None]:

# is it on the whitelist?
if settings.ENABLE_PEER_WHITELIST and peer.id not in protocol.node.peers_whitelist:
protocol.send_error_and_close_connection('Blocked (id={}). Get in touch with Hathor team.'.format(peer.id))
if settings.WHITELIST_WARN_BLOCKED_PEERS:
protocol.send_error_and_close_connection(f'Blocked (by {peer.id}). Get in touch with Hathor team.')
else:
protocol.send_error_and_close_connection('Connection rejected.')
return

if peer.id == protocol.my_peer.id:
Expand Down