Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

Commit

Permalink
limit update notifications to bootstrap nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
etam committed Feb 12, 2020
1 parent 8c3c75a commit 9f07357
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions golem/network/p2p/peersession.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ def _react_to_hello(self, msg):
logger.error("Received unexpected Hello message, ignoring")
return

# Check if sender is a seed/bootstrap node
# Check if sender is a bootstrap node
port = getattr(msg, 'port', None)
if (self.address, port) in self.p2p_service.seeds:
if (self.address, port) in self.p2p_service.bootstrap_seeds:
compare_version(getattr(msg, 'client_ver', None))

if not self.conn.opened:
Expand Down
8 changes: 5 additions & 3 deletions tests/golem/network/p2p/test_peersession.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def test_handshake_client_randval(self, send_mock):
def test_react_to_hello_new_version(self):
listener = MagicMock()
dispatcher.connect(listener, signal='golem.p2p')
self.peer_session.p2p_service.seeds = {
self.peer_session.p2p_service.bootstrap_seeds = {
(host, random.randint(0, 65535))
for host in
ipaddress.ip_network('192.0.2.0/29').hosts()
Expand Down Expand Up @@ -273,7 +273,8 @@ def test_react_to_hello_new_version(self):
listener.reset_mock()

# Choose one seed
chosen_seed = random.choice(tuple(self.peer_session.p2p_service.seeds))
chosen_seed = random.choice(tuple(
self.peer_session.p2p_service.bootstrap_seeds))
msg_kwargs['port'] = chosen_seed[1]
self.peer_session.address = chosen_seed[0]

Expand Down Expand Up @@ -306,7 +307,8 @@ def test_react_to_hello_new_version_partial(self):
ipaddress.ip_network('192.0.2.0/29').hosts()
}
version = semantic_version.Version(golem.__version__)
chosen_seed = random.choice(tuple(self.peer_session.p2p_service.seeds))
chosen_seed = random.choice(tuple(
self.peer_session.p2p_service.bootstrap_seeds))
self.peer_session.address = chosen_seed[0]
msg = msg_factories.base.HelloFactory(
client_ver=f"{version.major}.{version.next_minor().minor}",
Expand Down

0 comments on commit 9f07357

Please sign in to comment.