diff --git a/src/_zkapauthorizer/_storage_server.py b/src/_zkapauthorizer/_storage_server.py index 8f883716a05dec68497317a914615c4e1e3d944c..69037cb368f32807f58226e0ca0d93bc805e2dba 100644 --- a/src/_zkapauthorizer/_storage_server.py +++ b/src/_zkapauthorizer/_storage_server.py @@ -555,6 +555,7 @@ def get_share_sizes(storage_server, storage_index_or_slot, sharenums): ) ) + def get_share_stats(storage_server, storage_index_or_slot, sharenums): """ Get the stats for the given share numbers for the given storage index *or* @@ -726,11 +727,13 @@ def add_leases_for_writev(storage_server, storage_index, secrets, tw_vectors, no owner_num=1, renew_secret=renew_secret, cancel_secret=cancel_secret, - expiration_time=now + ZKAPAuthorizerStorageServer.LEASE_PERIOD.total_seconds(), + expiration_time=now + + ZKAPAuthorizerStorageServer.LEASE_PERIOD.total_seconds(), nodeid=storage_server.my_nodeid, ), ) + def get_share_path(storage_server, storage_index, sharenum): # type: (StorageServer, bytes, int) -> FilePath """ diff --git a/src/_zkapauthorizer/tests/test_storage_protocol.py b/src/_zkapauthorizer/tests/test_storage_protocol.py index 5aa07a7380f96071ea72771cbe647e7f3a585191..6e3fd1222470ab0959d8f936177c1f1d78ba68d0 100644 --- a/src/_zkapauthorizer/tests/test_storage_protocol.py +++ b/src/_zkapauthorizer/tests/test_storage_protocol.py @@ -875,15 +875,17 @@ class ShareTests(TestCase): # time for a given share number to be updated here. Only # sharenums being written for the first time will capture the time # here. - grant_times.update({ - # The time is in a list to make it easier to compare the - # result with the return value of `get_lease_grant_times` - # later. The time is truncated to the integer portion because - # that is how much precision leases keep. - sharenum: [int(self.clock.seconds())] - for sharenum in vector - if sharenum not in grant_times - }) + grant_times.update( + { + # The time is in a list to make it easier to compare the + # result with the return value of `get_lease_grant_times` + # later. The time is truncated to the integer portion + # because that is how much precision leases keep. + sharenum: [int(self.clock.seconds())] + for sharenum in vector + if sharenum not in grant_times + } + ) # Advance time so the grant times will be distinct. self.clock.advance(1) @@ -905,10 +907,12 @@ class ShareTests(TestCase): # And the lease we paid for on every share is present. self.assertThat( - dict(get_lease_grant_times( - self.anonymous_storage_server, - storage_index, - )), + dict( + get_lease_grant_times( + self.anonymous_storage_server, + storage_index, + ) + ), Equals(grant_times), ) @@ -1105,6 +1109,7 @@ def write_vector_to_read_vector(write_vector): """ return (write_vector[0], len(write_vector[1])) + def get_lease_grant_times(storage_server, storage_index): """ Get the grant times for all of the leases for all of the shares at the @@ -1114,7 +1119,5 @@ def get_lease_grant_times(storage_server, storage_index): for sharenum, sharepath in shares: sharefile = get_share_file(sharepath) leases = sharefile.get_leases() - grant_times = list( - lease.get_grant_renew_time_time() for lease in leases - ) + grant_times = list(lease.get_grant_renew_time_time() for lease in leases) yield sharenum, grant_times