verida / storage-node

ISC License
3 stars 5 forks source link

Support storage limits #41

Closed tahpot closed 1 year ago

tahpot commented 1 year ago

Support storage nodes setting a storage limit per user's application context and limiting the maximum number of users they support.

This will enable user's to pre-purchase specific amounts of storage capacity that will be enforced by storage nodes.

This can be enforced by checking the storage limit at the following endpoints:

This allows a user to obtain a refresh token, but not an access token. The user can also delete databases, but can't create or update them.

Tasks:

Note: A user could exceed the storage limit during a given session, but there's no point as once their access token expires they will no longer have access to the data.

Note: A "user" is actually a combination of DID and application context

tahpot commented 1 year ago

Example response from /user/status:

{
  status: 'success',
  result: {
    databases: 2,
    bytes: 58052,
    storageLimit: 104857600,
    usagePercent: 0.0006
  },
  signature: '0xb101725aa23e9dc2b51e584f579bdc21f04b956b342c6d0f5ff4a3875993a96e37e6fecf896a2b1be14d3eff0cfa798ec5adcb3cc5918ec1a74522d67874265e1b'
}

Example response from /status:

{
  status: 'success',
  results: { maxUsers: 10000, currentUsers: 90, version: '1.2.0' },
  signature: '0x43efe05bcb07e6ca0ee2822c8bcf2421f5640107f320404a86e0f36fffde98997604bbead86602f29a3339aa3973c56809c15a6165db1a568727bbd994e37f921c'
}