At the moment the only way to manually remove objects is to to remove their individual blocks, with the Blockstore::Delete(force) RPC. The way data removal is conducted should be slightly adjusted, leaving the forceful delete method for backwards compatability.
The new RPC should perform the following steps when giving a CID to delete:
- Pull its reference counter entry
- If the entry has links, iterate over all of its links (and if those links have links, do the same, etc...), calling the
DeleteBlock function on each link
- Finally after doing this on all links, and their descendants, call the
DeleteBlock function on the CID given in the RPC request
If any reference count entries have a reference count of >= 1 after this RPC is done being processed, it means that it is referred to by other objects and wont be removed until those objects are removed.
To do this, the reference counter will need to be modified to include the links within the reference count entry. As such this means a migration will need to be ran if the reference counted blockstore has previous items in it. This is a pretty simple thing to do as all we need to do is decode the block into an IPLD type, see if it has links, and add those to the reference counter protocol buffer entry.
To deal with the migration I'm thinking we can use a marker key in the reference counter datastore using a key named something like is-linkable. IF this key isn't present it means that the reference counter isn't yet one that enables link decoding, which means we need to do a migration that goes through all CIDs, and makes sure to add the links to the reference counter entry, after which we add a marker key. Overall the migration should be pretty fast as all we would need to do is run AllKeysChan, for each CID pull the block from the blockstore, decode it into an ipld.Node type, get its Links and add that to the entry.Links field.
This new RPC would also be able to be integrated into s3x and give us the utility to enable removal of objects
@xiegeo thoughts on the proposed solution?
At the moment the only way to manually remove objects is to to remove their individual blocks, with the
Blockstore::Delete(force)RPC. The way data removal is conducted should be slightly adjusted, leaving the forceful delete method for backwards compatability.The new RPC should perform the following steps when giving a CID to delete:
DeleteBlockfunction on each linkDeleteBlockfunction on the CID given in the RPC requestIf any reference count entries have a reference count of >= 1 after this RPC is done being processed, it means that it is referred to by other objects and wont be removed until those objects are removed.
To do this, the reference counter will need to be modified to include the links within the reference count entry. As such this means a migration will need to be ran if the reference counted blockstore has previous items in it. This is a pretty simple thing to do as all we need to do is decode the block into an IPLD type, see if it has links, and add those to the reference counter protocol buffer entry.
To deal with the migration I'm thinking we can use a marker key in the reference counter datastore using a key named something like
is-linkable. IF this key isn't present it means that the reference counter isn't yet one that enables link decoding, which means we need to do a migration that goes through all CIDs, and makes sure to add the links to the reference counter entry, after which we add a marker key. Overall the migration should be pretty fast as all we would need to do is runAllKeysChan, for each CID pull the block from the blockstore, decode it into anipld.Nodetype, get itsLinksand add that to theentry.Linksfield.This new RPC would also be able to be integrated into s3x and give us the utility to enable removal of objects
@xiegeo thoughts on the proposed solution?