Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
f1d5c2f2
Unverified
Commit
f1d5c2f2
authored
3 years ago
by
Eric Eastwood
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Split out federated PDU retrieval into a non-cached version (#11242)
Context:
https://github.com/matrix-org/synapse/pull/11114/files#r741643968
parent
0ef69ddb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
changelog.d/11242.misc
+1
-0
1 addition, 0 deletions
changelog.d/11242.misc
synapse/federation/federation_client.py
+58
-22
58 additions, 22 deletions
synapse/federation/federation_client.py
with
59 additions
and
22 deletions
changelog.d/11242.misc
0 → 100644
+
1
−
0
View file @
f1d5c2f2
Split out federated PDU retrieval function into a non-cached version.
This diff is collapsed.
Click to expand it.
synapse/federation/federation_client.py
+
58
−
22
View file @
f1d5c2f2
...
...
@@ -277,6 +277,58 @@ class FederationClient(FederationBase):
return
pdus
async
def
get_pdu_from_destination_raw
(
self
,
destination
:
str
,
event_id
:
str
,
room_version
:
RoomVersion
,
outlier
:
bool
=
False
,
timeout
:
Optional
[
int
]
=
None
,
)
->
Optional
[
EventBase
]:
"""
Requests the PDU with given origin and ID from the remote home
server. Does not have any caching or rate limiting!
Args:
destination: Which homeserver to query
event_id: event to fetch
room_version: version of the room
outlier: Indicates whether the PDU is an `outlier`, i.e. if
it
'
s from an arbitrary point in the context as opposed to part
of the current block of PDUs. Defaults to `False`
timeout: How long to try (in ms) each destination for before
moving to the next destination. None indicates no timeout.
Returns:
The requested PDU, or None if we were unable to find it.
Raises:
SynapseError, NotRetryingDestination, FederationDeniedError
"""
transaction_data
=
await
self
.
transport_layer
.
get_event
(
destination
,
event_id
,
timeout
=
timeout
)
logger
.
debug
(
"
retrieved event id %s from %s: %r
"
,
event_id
,
destination
,
transaction_data
,
)
pdu_list
:
List
[
EventBase
]
=
[
event_from_pdu_json
(
p
,
room_version
,
outlier
=
outlier
)
for
p
in
transaction_data
[
"
pdus
"
]
]
if
pdu_list
and
pdu_list
[
0
]:
pdu
=
pdu_list
[
0
]
# Check signatures are correct.
signed_pdu
=
await
self
.
_check_sigs_and_hash
(
room_version
,
pdu
)
return
signed_pdu
return
None
async
def
get_pdu
(
self
,
destinations
:
Iterable
[
str
],
...
...
@@ -321,30 +373,14 @@ class FederationClient(FederationBase):
continue
try
:
transaction_data
=
await
self
.
transport_layer
.
get_event
(
destination
,
event_id
,
timeout
=
timeout
)
logger
.
debug
(
"
retrieved event id %s from %s: %r
"
,
event_id
,
destination
,
transaction_data
,
signed_pdu
=
await
self
.
get_pdu_from_destination_raw
(
destination
=
destination
,
event_id
=
event_id
,
room_version
=
room_version
,
outlier
=
outlier
,
timeout
=
timeout
,
)
pdu_list
:
List
[
EventBase
]
=
[
event_from_pdu_json
(
p
,
room_version
,
outlier
=
outlier
)
for
p
in
transaction_data
[
"
pdus
"
]
]
if
pdu_list
and
pdu_list
[
0
]:
pdu
=
pdu_list
[
0
]
# Check signatures are correct.
signed_pdu
=
await
self
.
_check_sigs_and_hash
(
room_version
,
pdu
)
break
pdu_attempts
[
destination
]
=
now
except
SynapseError
as
e
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment