add get_available_space() to NativeStorageServer
It uses a new 'available-space' key in the server's v1 version dict, or falls
back to 'maximum-immutable-share-size' (which presently always has the same
value but could have a different meaning in the future).
This is a squash merge of
9773555bb87fab71145ad7a0e84785a4e92d11f7
version = { "http://allmydata.org/tahoe/protocols/storage/v1" :
{ "maximum-immutable-share-size": remaining_space,
"maximum-mutable-share-size": MAX_MUTABLE_SHARE_SIZE,
+ "available-space": remaining_space,
"tolerates-immutable-read-overrun": True,
"delete-mutable-shares-with-zero-length-writev": True,
"fills-holes-with-zero-bytes": True,
def get_announcement_time(self):
return self.announcement_time
+ def get_available_space(self):
+ version = self.get_version()
+ if version is None:
+ return None
+ protocol_v1_version = version.get('http://allmydata.org/tahoe/protocols/storage/v1', {})
+ available_space = protocol_v1_version.get('available-space')
+ if available_space is None:
+ available_space = protocol_v1_version.get('maximum-immutable-share-size', None)
+ return available_space
+
def start_connecting(self, tub, trigger_cb):
furl = str(self.announcement["anonymous-storage-FURL"])
self._trigger_cb = trigger_cb
return self.announcement
def get_nickname(self):
return self.announcement["nickname"]
+ def get_available_space(self):
+ return 0
class FakeBucketCounter(object):
def get_state(self):
announcement = server.get_announcement()
version = announcement["my-version"]
service_name = announcement["service-name"]
-
+ available_space = server.get_available_space()
+ if available_space is None:
+ available_space = "N/A"
+ else:
+ available_space = abbreviate_size(available_space)
ctx.fillSlots("address", addr)
ctx.fillSlots("connected", connected)
ctx.fillSlots("connected-bool", bool(rhost))
time.localtime(announced)))
ctx.fillSlots("version", version)
ctx.fillSlots("service_name", service_name)
+ ctx.fillSlots("available_space", available_space)
return ctx.tag
<td><h3>Since</h3></td>
<td><h3>Announced</h3></td>
<td><h3>Version</h3></td>
+ <td><h3>Available</h3></td>
</tr>
</thead>
<tr n:pattern="item" n:render="service_row">
<td class="service-since timestamp"><n:slot name="since"/></td>
<td class="service-announced timestamp"><n:slot name="announced"/></td>
<td class="service-version"><n:slot name="version"/></td>
+ <td class="service-available-space"><n:slot name="available_space"/></td>
</tr>
<tr n:pattern="empty"><td>You are not presently connected to any peers</td></tr>
</table>