Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Matrix
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Operate
Environments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Matrix
Commits
1afafb34
Commit
1afafb34
authored
6 years ago
by
Adrian Tschira
Browse files
Options
Downloads
Patches
Plain Diff
use memoryview in py3
Signed-off-by:
Adrian Tschira
<
nota@notafile.com
>
parent
235b5326
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
synapse/storage/keys.py
+8
-0
8 additions, 0 deletions
synapse/storage/keys.py
synapse/storage/signatures.py
+10
-2
10 additions, 2 deletions
synapse/storage/signatures.py
with
18 additions
and
2 deletions
synapse/storage/keys.py
+
8
−
0
View file @
1afafb34
...
...
@@ -17,6 +17,7 @@ from ._base import SQLBaseStore
from
synapse.util.caches.descriptors
import
cachedInlineCallbacks
from
twisted.internet
import
defer
import
six
import
OpenSSL
from
signedjson.key
import
decode_verify_key_bytes
...
...
@@ -26,6 +27,13 @@ import logging
logger
=
logging
.
getLogger
(
__name__
)
# py2 sqlite has buffer hardcoded as only binary type, so we must use it,
# despite being deprecated and removed in favor of memoryview
if
six
.
PY2
:
db_binary_type
=
buffer
else
:
db_binary_type
=
memoryview
class
KeyStore
(
SQLBaseStore
):
"""
Persistence for signature verification keys and tls X.509 certificates
...
...
This diff is collapsed.
Click to expand it.
synapse/storage/signatures.py
+
10
−
2
View file @
1afafb34
...
...
@@ -14,6 +14,7 @@
# limitations under the License.
from
twisted.internet
import
defer
import
six
from
._base
import
SQLBaseStore
...
...
@@ -21,6 +22,13 @@ from unpaddedbase64 import encode_base64
from
synapse.crypto.event_signing
import
compute_event_reference_hash
from
synapse.util.caches.descriptors
import
cached
,
cachedList
# py2 sqlite has buffer hardcoded as only binary type, so we must use it,
# despite being deprecated and removed in favor of memoryview
if
six
.
PY2
:
db_binary_type
=
buffer
else
:
db_binary_type
=
memoryview
class
SignatureWorkerStore
(
SQLBaseStore
):
@cached
()
...
...
@@ -56,7 +64,7 @@ class SignatureWorkerStore(SQLBaseStore):
for
e_id
,
h
in
hashes
.
items
()
}
defer
.
returnValue
(
hashes
.
items
())
defer
.
returnValue
(
list
(
hashes
.
items
())
)
def
_get_event_reference_hashes_txn
(
self
,
txn
,
event_id
):
"""
Get all the hashes for a given PDU.
...
...
@@ -91,7 +99,7 @@ class SignatureStore(SignatureWorkerStore):
vals
.
append
({
"
event_id
"
:
event
.
event_id
,
"
algorithm
"
:
ref_alg
,
"
hash
"
:
buffer
(
ref_hash_bytes
),
"
hash
"
:
db_binary_type
(
ref_hash_bytes
),
})
self
.
_simple_insert_many_txn
(
...
...
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