mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-20 05:28:04 +00:00
Progress on implementing client side of mutable writes.
This commit is contained in:
parent
24548dee0b
commit
b0d547ee53
@ -8,7 +8,7 @@ from typing import Union, Set, Optional
|
|||||||
from enum import Enum
|
from enum import Enum
|
||||||
from base64 import b64encode
|
from base64 import b64encode
|
||||||
|
|
||||||
from attrs import define, field
|
from attrs import define, field, asdict
|
||||||
|
|
||||||
# TODO Make sure to import Python version?
|
# TODO Make sure to import Python version?
|
||||||
from cbor2 import loads, dumps
|
from cbor2 import loads, dumps
|
||||||
@ -288,6 +288,7 @@ class StorageClient(object):
|
|||||||
lease_renew_secret=None,
|
lease_renew_secret=None,
|
||||||
lease_cancel_secret=None,
|
lease_cancel_secret=None,
|
||||||
upload_secret=None,
|
upload_secret=None,
|
||||||
|
write_enabler_secret=None,
|
||||||
headers=None,
|
headers=None,
|
||||||
message_to_serialize=None,
|
message_to_serialize=None,
|
||||||
**kwargs
|
**kwargs
|
||||||
@ -306,6 +307,7 @@ class StorageClient(object):
|
|||||||
(Secrets.LEASE_RENEW, lease_renew_secret),
|
(Secrets.LEASE_RENEW, lease_renew_secret),
|
||||||
(Secrets.LEASE_CANCEL, lease_cancel_secret),
|
(Secrets.LEASE_CANCEL, lease_cancel_secret),
|
||||||
(Secrets.UPLOAD, upload_secret),
|
(Secrets.UPLOAD, upload_secret),
|
||||||
|
(Secrets.WRITE_ENABLER, write_enabler_secret),
|
||||||
]:
|
]:
|
||||||
if value is None:
|
if value is None:
|
||||||
continue
|
continue
|
||||||
@ -651,8 +653,9 @@ class StorageClientMutables:
|
|||||||
|
|
||||||
@async_to_deferred
|
@async_to_deferred
|
||||||
async def read_test_write_chunks(
|
async def read_test_write_chunks(
|
||||||
|
self,
|
||||||
storage_index: bytes,
|
storage_index: bytes,
|
||||||
write_enabled_secret: bytes,
|
write_enabler_secret: bytes,
|
||||||
lease_renew_secret: bytes,
|
lease_renew_secret: bytes,
|
||||||
lease_cancel_secret: bytes,
|
lease_cancel_secret: bytes,
|
||||||
testwrite_vectors: dict[int, TestWriteVectors],
|
testwrite_vectors: dict[int, TestWriteVectors],
|
||||||
@ -667,7 +670,31 @@ class StorageClientMutables:
|
|||||||
Given a mapping between share numbers and test/write vectors, the tests
|
Given a mapping between share numbers and test/write vectors, the tests
|
||||||
are done and if they are valid the writes are done.
|
are done and if they are valid the writes are done.
|
||||||
"""
|
"""
|
||||||
pass
|
# TODO unit test all the things
|
||||||
|
url = self._client.relative_url(
|
||||||
|
"/v1/mutable/{}/read-test-write".format(_encode_si(storage_index))
|
||||||
|
)
|
||||||
|
message = {
|
||||||
|
"test-write-vectors": {
|
||||||
|
share_number: asdict(twv)
|
||||||
|
for (share_number, twv) in testwrite_vectors.items()
|
||||||
|
},
|
||||||
|
"read-vector": [asdict(r) for r in read_vector],
|
||||||
|
}
|
||||||
|
response = yield self._client.request(
|
||||||
|
"POST",
|
||||||
|
url,
|
||||||
|
write_enabler_secret=write_enabler_secret,
|
||||||
|
lease_renew_secret=lease_renew_secret,
|
||||||
|
lease_cancel_secret=lease_cancel_secret,
|
||||||
|
message_to_serialize=message,
|
||||||
|
)
|
||||||
|
if response.code == http.OK:
|
||||||
|
return _decode_cbor(response, _SCHEMAS["mutable_test_read_write"])
|
||||||
|
else:
|
||||||
|
raise ClientException(
|
||||||
|
response.code,
|
||||||
|
)
|
||||||
|
|
||||||
@async_to_deferred
|
@async_to_deferred
|
||||||
async def read_share_chunk(
|
async def read_share_chunk(
|
||||||
|
Loading…
Reference in New Issue
Block a user