From 9f76baed2f33ccb9cab592a5c1de90478f084f01 Mon Sep 17 00:00:00 2001
From: Jean-Paul Calderone <exarkun@twistedmatrix.com>
Date: Mon, 24 Feb 2020 15:59:38 -0500
Subject: [PATCH] Turns out we will probably be able to pass in all share sizes

---
 src/_zkapauthorizer/model.py            | 11 +++--------
 src/_zkapauthorizer/tests/test_model.py |  4 +++-
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/_zkapauthorizer/model.py b/src/_zkapauthorizer/model.py
index 8a3b8ec..2dff026 100644
--- a/src/_zkapauthorizer/model.py
+++ b/src/_zkapauthorizer/model.py
@@ -533,16 +533,11 @@ class LeaseMaintenance(object):
         self._rowid = cursor.lastrowid
 
     @with_cursor
-    def observe(self, cursor, size):
+    def observe(self, cursor, sizes):
         """
-        Record a storage object of a given size.
+        Record a storage shares of the given sizes.
         """
-        # XXX The client has no idea how many shares a server is storing and
-        # can do nothing except renew the lease on all of them. :( Here, guess
-        # that there is only one share.  "Servers of happiness" should make
-        # this more likely to be the case...  We might be underestimating
-        # storage costs though.
-        count = required_passes(BYTES_PER_PASS, {size})
+        count = required_passes(BYTES_PER_PASS, sizes)
         cursor.execute(
             """
             UPDATE [lease-maintenance-spending]
diff --git a/src/_zkapauthorizer/tests/test_model.py b/src/_zkapauthorizer/tests/test_model.py
index 018eb07..be418c0 100644
--- a/src/_zkapauthorizer/tests/test_model.py
+++ b/src/_zkapauthorizer/tests/test_model.py
@@ -297,7 +297,9 @@ class LeaseMaintenanceTests(TestCase):
             passes_required = 0
             for (num_passes, trim_size) in sizes:
                 passes_required += num_passes
-                x.observe(num_passes * BYTES_PER_PASS - trim_size)
+                x.observe({
+                    num_passes * BYTES_PER_PASS - trim_size
+                })
             now += finish_delay
             x.finish()
             finished = now
-- 
GitLab