Add an interface to publish the cost (in ZKAPs) of stored data, as observed during the last lease crawl
To allow users to plan their storage usage and their purchasing of new ZKAPs, it would be helpful for them to know what it costs to maintain the data they currently have stored.
The lease renewal process defines the cost of this maintenance. As currently implemented, it periodically visits all files reachable from a root capability and renews leases of all objects found if they don't already have a lease of at least some configurable duration.
Lease renewal costs a number of ZKAPs proportional to the size of the object, with quantization. This makes the total cost of maintaining objects for one period equal to:
maintenanceCost = sum
[ quantizedSize(object) / ZKAPValue
| object <- reachableObjects(rootCap)
]
And this value should be exposed in the HTTP API somewhere. A client UX can then estimate time to ZKAP depletion by dividing the number of ZKAPs left by the cost to maintain objects:
estimatedDepletion = remainingZKAPs / maintenanceCost * leasePeriod
The HTTP API should present the information like so:
GET /v1/unblinded-token
200 OK
Content-Type: application/json
{ ...
, "lease-maintenance-spending": {
"when": <ISO8601 timestamp>
, "amount": <integer ZKAP count>
}
}
where "when" gives an approximate timestamp when the spending took place and "amount" gives the number ZKAPs which were spent on lease maintenance.
If lease maintenance has never been performed then the value for lease-maintenance-spending
will be null
instead.