Skip to content

Commit 2cac33d

Browse files
committed
Return PFS broadcast room id in info response
This is necessary after - raiden-network/raiden-service-bundle#187 - raiden-network/raiden#6442 With those PRs the set of federation servers can become disjunct between different Raiden client versions. Therefore we can't rely on the previous check in the Raiden client if the PFS' server is in the known servers set. The RoomID is uniquely identifying a specific broadcasting room and can therefore be used as a better information source for this check.
1 parent e120059 commit 2cac33d

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

pyproject.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[tool.black]
2+
line-length = 99
3+
target-version = ['py37']
4+
include = '\.pyi?$'
5+
exclude = '''
6+
/(
7+
\.git
8+
| \.mypy_cache
9+
| \.tox
10+
| \.venv
11+
| build
12+
| dist
13+
)/
14+
'''

src/pathfinding_service/api.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ def get(self) -> Tuple[dict, int]:
417417
"payment_address": to_checksum_address(self.pathfinding_service.address),
418418
"UTC": datetime.utcnow().isoformat(),
419419
"matrix_server": self.api.pathfinding_service.matrix_listener.base_url,
420+
"matrix_room_id": self.api.pathfinding_service.matrix_listener.broadcast_room_id,
420421
}
421422
return info, 200
422423

@@ -445,7 +446,10 @@ def get(self, token_network_address: str) -> Tuple[List[Dict[str, Any]], int]:
445446

446447
class DebugPathResource(PathfinderResource):
447448
def get( # pylint: disable=no-self-use
448-
self, token_network_address: str, source_address: str, target_address: Optional[str] = None
449+
self,
450+
token_network_address: str,
451+
source_address: str,
452+
target_address: Optional[str] = None,
449453
) -> Tuple[dict, int]:
450454
request_count = 0
451455
responses = []

src/raiden_libs/matrix.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
from raiden.storage.serialization.serializer import MessageSerializer
4242
from raiden.utils.cli import get_matrix_servers
4343
from raiden.utils.signer import LocalSigner
44-
from raiden.utils.typing import Address, ChainID
44+
from raiden.utils.typing import Address, ChainID, RoomID
4545
from raiden_contracts.utils.type_aliases import PrivateKey
4646

4747
log = structlog.get_logger(__name__)
@@ -162,6 +162,7 @@ def __init__(
162162
http_retry_timeout=40,
163163
http_retry_delay=matrix_http_retry_delay,
164164
)
165+
self.broadcast_room_id: Optional[RoomID] = None
165166
self._broadcast_room: Optional[Room] = None
166167
self._displayname_cache = DisplayNameCache()
167168
self.base_url = self._client.api.base_url
@@ -205,10 +206,7 @@ def _start_client(self) -> None:
205206
try:
206207
self.user_manager.start()
207208

208-
login(
209-
self._client,
210-
signer=LocalSigner(private_key=self.private_key),
211-
)
209+
login(self._client, signer=LocalSigner(private_key=self.private_key))
212210
except (MatrixRequestError, ValueError):
213211
raise ConnectionError("Could not login/register to matrix.")
214212

@@ -219,6 +217,7 @@ def _start_client(self) -> None:
219217
self._broadcast_room = join_broadcast_room(
220218
client=self._client, broadcast_room_alias=room_alias
221219
)
220+
self.broadcast_room_id = self._broadcast_room.room_id
222221

223222
sync_filter_id = self._client.create_sync_filter(rooms=[self._broadcast_room])
224223
self._client.set_sync_filter_id(sync_filter_id)
@@ -231,8 +230,7 @@ def follow_address_presence(self, address: Address, refresh: bool = False) -> No
231230
if refresh:
232231
self.user_manager.populate_userids_for_address(address)
233232
self.user_manager.track_address_presence(
234-
address=address,
235-
user_ids=self.user_manager.get_userids_for_address(address),
233+
address=address, user_ids=self.user_manager.get_userids_for_address(address)
236234
)
237235

238236
log.debug(

0 commit comments

Comments
 (0)