diff options
author | reivilibre <oliverw@matrix.org> | 2023-04-13 14:35:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-13 15:35:03 +0100 |
commit | edae20f926d9d1225111f1d40a1073ce3f1d3fb7 (patch) | |
tree | 900cb6fdfa14849a766f009655911ab0e52e9249 /synapse/storage | |
parent | Add comma missing from #15382. (#15429) (diff) | |
download | synapse-edae20f926d9d1225111f1d40a1073ce3f1d3fb7.tar.xz |
Improve robustness when handling a perspective key response by deduplicating received server keys. (#15423)
* Change `store_server_verify_keys` to take a `Mapping[(str, str), FKR]` This is because we already can't handle duplicate keys — leads to cardinality violation * Newsfile Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <oliverw@matrix.org>
Diffstat (limited to 'synapse/storage')
-rw-r--r-- | synapse/storage/databases/main/keys.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/synapse/storage/databases/main/keys.py b/synapse/storage/databases/main/keys.py index 0a19f607bd..89c37a4eb5 100644 --- a/synapse/storage/databases/main/keys.py +++ b/synapse/storage/databases/main/keys.py @@ -15,7 +15,7 @@ import itertools import logging -from typing import Any, Dict, Iterable, List, Optional, Tuple +from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple from signedjson.key import decode_verify_key_bytes @@ -95,7 +95,7 @@ class KeyStore(SQLBaseStore): self, from_server: str, ts_added_ms: int, - verify_keys: Iterable[Tuple[str, str, FetchKeyResult]], + verify_keys: Mapping[Tuple[str, str], FetchKeyResult], ) -> None: """Stores NACL verification keys for remote servers. Args: @@ -108,7 +108,7 @@ class KeyStore(SQLBaseStore): key_values = [] value_values = [] invalidations = [] - for server_name, key_id, fetch_result in verify_keys: + for (server_name, key_id), fetch_result in verify_keys.items(): key_values.append((server_name, key_id)) value_values.append( ( |