@@ -277,6 +277,58 @@ async def backfill(
277
277
278
278
return pdus
279
279
280
+ async def get_pdu_from_destination_raw (
281
+ self ,
282
+ destination : str ,
283
+ event_id : str ,
284
+ room_version : RoomVersion ,
285
+ outlier : bool = False ,
286
+ timeout : Optional [int ] = None ,
287
+ ) -> Optional [EventBase ]:
288
+ """Requests the PDU with given origin and ID from the remote home
289
+ server. Does not have any caching or rate limiting!
290
+
291
+ Args:
292
+ destination: Which homeserver to query
293
+ event_id: event to fetch
294
+ room_version: version of the room
295
+ outlier: Indicates whether the PDU is an `outlier`, i.e. if
296
+ it's from an arbitrary point in the context as opposed to part
297
+ of the current block of PDUs. Defaults to `False`
298
+ timeout: How long to try (in ms) each destination for before
299
+ moving to the next destination. None indicates no timeout.
300
+
301
+ Returns:
302
+ The requested PDU, or None if we were unable to find it.
303
+
304
+ Raises:
305
+ SynapseError, NotRetryingDestination, FederationDeniedError
306
+ """
307
+ transaction_data = await self .transport_layer .get_event (
308
+ destination , event_id , timeout = timeout
309
+ )
310
+
311
+ logger .debug (
312
+ "retrieved event id %s from %s: %r" ,
313
+ event_id ,
314
+ destination ,
315
+ transaction_data ,
316
+ )
317
+
318
+ pdu_list : List [EventBase ] = [
319
+ event_from_pdu_json (p , room_version , outlier = outlier )
320
+ for p in transaction_data ["pdus" ]
321
+ ]
322
+
323
+ if pdu_list and pdu_list [0 ]:
324
+ pdu = pdu_list [0 ]
325
+
326
+ # Check signatures are correct.
327
+ signed_pdu = await self ._check_sigs_and_hash (room_version , pdu )
328
+ return signed_pdu
329
+
330
+ return None
331
+
280
332
async def get_pdu (
281
333
self ,
282
334
destinations : Iterable [str ],
@@ -321,30 +373,14 @@ async def get_pdu(
321
373
continue
322
374
323
375
try :
324
- transaction_data = await self .transport_layer .get_event (
325
- destination , event_id , timeout = timeout
326
- )
327
-
328
- logger .debug (
329
- "retrieved event id %s from %s: %r" ,
330
- event_id ,
331
- destination ,
332
- transaction_data ,
376
+ signed_pdu = await self .get_pdu_from_destination_raw (
377
+ destination = destination ,
378
+ event_id = event_id ,
379
+ room_version = room_version ,
380
+ outlier = outlier ,
381
+ timeout = timeout ,
333
382
)
334
383
335
- pdu_list : List [EventBase ] = [
336
- event_from_pdu_json (p , room_version , outlier = outlier )
337
- for p in transaction_data ["pdus" ]
338
- ]
339
-
340
- if pdu_list and pdu_list [0 ]:
341
- pdu = pdu_list [0 ]
342
-
343
- # Check signatures are correct.
344
- signed_pdu = await self ._check_sigs_and_hash (room_version , pdu )
345
-
346
- break
347
-
348
384
pdu_attempts [destination ] = now
349
385
350
386
except SynapseError as e :
0 commit comments