Skip to content

Commit 2e674ce

Browse files
committed
Make discovery v5 available in full mode
1 parent 6d48061 commit 2e674ce

File tree

5 files changed

+14
-12
lines changed

5 files changed

+14
-12
lines changed

tests/p2p/test_discovery.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515

1616
from cancel_token import CancelToken
1717

18-
from eth.chains.ropsten import ROPSTEN_GENESIS_HEADER
19-
20-
from trinity.protocol.les.proto import LESProtocol, LESProtocolV2
21-
2218
from p2p import discovery
2319
from p2p import kademlia
2420

@@ -370,13 +366,6 @@ def test_topic_table():
370366
assert node2 not in table.get_nodes(topic)
371367

372368

373-
def test_get_v5_topic():
374-
les_topic = discovery.get_v5_topic(LESProtocol, ROPSTEN_GENESIS_HEADER.hash)
375-
assert les_topic == b'LES@41941023680923e0'
376-
les2_topic = discovery.get_v5_topic(LESProtocolV2, ROPSTEN_GENESIS_HEADER.hash)
377-
assert les2_topic == b'LES2@41941023680923e0'
378-
379-
380369
def remove_whitespace(s):
381370
return re.sub(r"\s+", "", s)
382371

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from eth.chains.ropsten import ROPSTEN_GENESIS_HEADER
2+
3+
from p2p import discovery
4+
5+
from trinity.protocol.les.proto import LESProtocol, LESProtocolV2
6+
7+
8+
def test_get_v5_topic():
9+
les_topic = discovery.get_v5_topic(LESProtocol, ROPSTEN_GENESIS_HEADER.hash)
10+
assert les_topic == b'LES@41941023680923e0'
11+
les2_topic = discovery.get_v5_topic(LESProtocolV2, ROPSTEN_GENESIS_HEADER.hash)
12+
assert les2_topic == b'LES2@41941023680923e0'

trinity/nodes/base.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def __init__(self, event_bus: Endpoint, trinity_config: TrinityConfig) -> None:
4949

5050
self._jsonrpc_ipc_path: Path = trinity_config.jsonrpc_ipc_path
5151
self._network_id = trinity_config.network_id
52+
self._use_discv5 = trinity_config.use_discv5
5253

5354
self.event_bus = event_bus
5455

trinity/nodes/full.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def get_p2p_server(self) -> FullServer:
4747
max_peers=self._max_peers,
4848
bootstrap_nodes=self._bootstrap_nodes,
4949
preferred_nodes=self._preferred_nodes,
50+
use_discv5=self._use_discv5,
5051
token=self.cancel_token,
5152
event_bus=self.event_bus,
5253
)

trinity/nodes/light.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def __init__(self, event_bus: Endpoint, trinity_config: TrinityConfig) -> None:
3737
self._max_peers = trinity_config.max_peers
3838
self._bootstrap_nodes = trinity_config.bootstrap_nodes
3939
self._preferred_nodes = trinity_config.preferred_nodes
40-
self._use_discv5 = trinity_config.use_discv5
4140

4241
self._peer_chain = LightPeerChain(
4342
self.headerdb,

0 commit comments

Comments
 (0)