How to update DHT after garbage collection?

When a node runs ipfs cat or ipfs get to retrieve a file which does not exist in its local storage, the node will download the file from peers by looking at the DHT, and then cache the downloaded file. At this moment, ipfs dht findprovs shows that the node is on the DHT list, which is normal and reasonable because the node does have a copy of the file for sharing.

But later when the node runs ipfs repo gc, the cached file is deleted. This time, ipfs dht findprovs still shows that the node is still on the DHT list. However, since the file is garbage collected, the node cannot help the download. Is there anything the node can do after garbage collection to update DHT such that DHT can reflect the truth which files the node has.

1 Like

At the moment no, we just wait until the provider records expire (24 hours, I think?). In general, deleting records from DHTs is difficult to impossible; all you can really do is replace it with a record saying “this other record is invalid”. Also, publishing (and deleting) provider records is time consuming so we’d like to avoid doing so when possible.

It may make sense to have some way to delete provider records for popular content (on a best-effort, when necessary basis). However, figuring out how to do that correctly is non-trivial so it’s not really a priority (this isn’t really a burning issue at the moment so it’s unclear if deleting provider records will save much bandwidth).