Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
mypy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
richvdh committed Oct 2, 2020
1 parent 2187fe2 commit 4594e4b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions synapse/federation/sender/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ async def _send_pdu(self, pdu: EventBase, destinations: Iterable[str]) -> None:
sent_pdus_destination_dist_total.inc(len(destinations))
sent_pdus_destination_dist_count.inc()

assert pdu.internal_metadata.stream_ordering

# track the fact that we have a PDU for these destinations,
# to allow us to perform catch-up later on if the remote is unreachable
# for a while.
Expand Down
2 changes: 2 additions & 0 deletions synapse/federation/sender/per_destination_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def send_pdu(self, pdu: EventBase) -> None:
# yet know if we have anything to catch up (None)
self._pending_pdus.append(pdu)
else:
assert pdu.internal_metadata.stream_ordering
self._catchup_last_skipped = pdu.internal_metadata.stream_ordering

self.attempt_new_transaction()
Expand Down Expand Up @@ -361,6 +362,7 @@ async def _transaction_transmission_loop(self) -> None:
last_successful_stream_ordering = (
final_pdu.internal_metadata.stream_ordering
)
assert last_successful_stream_ordering
await self._store.set_destination_last_successful_stream_ordering(
self._destination, last_successful_stream_ordering
)
Expand Down
3 changes: 3 additions & 0 deletions synapse/handlers/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -3008,6 +3008,9 @@ async def _notify_persisted_event(
elif event.internal_metadata.is_outlier():
return

# the event has been persisted so it should have a stream ordering.
assert event.internal_metadata.stream_ordering

event_pos = PersistedEventPosition(
self._instance_name, event.internal_metadata.stream_ordering
)
Expand Down
4 changes: 4 additions & 0 deletions synapse/storage/databases/main/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ def _persist_events_txn(
min_stream_order = events_and_contexts[0][0].internal_metadata.stream_ordering
max_stream_order = events_and_contexts[-1][0].internal_metadata.stream_ordering

# stream orderings should have been assigned by now
assert min_stream_order
assert max_stream_order

self._update_forward_extremities_txn(
txn,
new_forward_extremities=new_forward_extremeties,
Expand Down
2 changes: 2 additions & 0 deletions synapse/storage/persist_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,8 @@ async def persist_event(
await make_deferred_yieldable(deferred)

event_stream_id = event.internal_metadata.stream_ordering
# stream ordering should have been assigned by now
assert event_stream_id

pos = PersistedEventPosition(self._instance_name, event_stream_id)
return pos, self.main_store.get_room_max_token()
Expand Down

0 comments on commit 4594e4b

Please sign in to comment.