Skip to content

Commit

Permalink
Make discovery v5 available in full mode
Browse files Browse the repository at this point in the history
  • Loading branch information
cburgdorf committed Nov 22, 2018
1 parent 6d48061 commit 2e674ce
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 12 deletions.
11 changes: 0 additions & 11 deletions tests/p2p/test_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

from cancel_token import CancelToken

from eth.chains.ropsten import ROPSTEN_GENESIS_HEADER

from trinity.protocol.les.proto import LESProtocol, LESProtocolV2

from p2p import discovery
from p2p import kademlia

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


def test_get_v5_topic():
les_topic = discovery.get_v5_topic(LESProtocol, ROPSTEN_GENESIS_HEADER.hash)
assert les_topic == b'LES@41941023680923e0'
les2_topic = discovery.get_v5_topic(LESProtocolV2, ROPSTEN_GENESIS_HEADER.hash)
assert les2_topic == b'LES2@41941023680923e0'


def remove_whitespace(s):
return re.sub(r"\s+", "", s)

Expand Down
12 changes: 12 additions & 0 deletions tests/trinity/core/p2p-proto/test_v5_les_protocol_topics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from eth.chains.ropsten import ROPSTEN_GENESIS_HEADER

from p2p import discovery

from trinity.protocol.les.proto import LESProtocol, LESProtocolV2


def test_get_v5_topic():
les_topic = discovery.get_v5_topic(LESProtocol, ROPSTEN_GENESIS_HEADER.hash)
assert les_topic == b'LES@41941023680923e0'
les2_topic = discovery.get_v5_topic(LESProtocolV2, ROPSTEN_GENESIS_HEADER.hash)
assert les2_topic == b'LES2@41941023680923e0'
1 change: 1 addition & 0 deletions trinity/nodes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def __init__(self, event_bus: Endpoint, trinity_config: TrinityConfig) -> None:

self._jsonrpc_ipc_path: Path = trinity_config.jsonrpc_ipc_path
self._network_id = trinity_config.network_id
self._use_discv5 = trinity_config.use_discv5

self.event_bus = event_bus

Expand Down
1 change: 1 addition & 0 deletions trinity/nodes/full.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def get_p2p_server(self) -> FullServer:
max_peers=self._max_peers,
bootstrap_nodes=self._bootstrap_nodes,
preferred_nodes=self._preferred_nodes,
use_discv5=self._use_discv5,
token=self.cancel_token,
event_bus=self.event_bus,
)
Expand Down
1 change: 0 additions & 1 deletion trinity/nodes/light.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def __init__(self, event_bus: Endpoint, trinity_config: TrinityConfig) -> None:
self._max_peers = trinity_config.max_peers
self._bootstrap_nodes = trinity_config.bootstrap_nodes
self._preferred_nodes = trinity_config.preferred_nodes
self._use_discv5 = trinity_config.use_discv5

self._peer_chain = LightPeerChain(
self.headerdb,
Expand Down

0 comments on commit 2e674ce

Please sign in to comment.