如何检查给定的 <ipfs_hash> 是否已完全下载?

How to check is the given <ipfs_hash> is already fully downloaded or not?

首先,当我 运行 ipfs --offline block stat <ipfs_hash> 时,如果散列在本地不存在,我会收到以下消息:Error: blockservice: key not found.

如何解决此问题以检测所询问的散列是否已完全下载?


我可以做类似 ipfs refs local | grep <hash> 的事情,但我不想一直获取所有哈希值,当存在​​数百个哈希值时它会变慢。

相关:https://discuss.ipfs.io/t/how-to-check-is-the-given-ipfs-hash-and-its-linked-hashes-already-downloaded-or-not/7588

ipfs files stat --with-local --size <path> returns 请求的 ipfs 哈希的下载百分比。如果它 100.00% 那么我们可以验证它是否已完全下载到本地 ipfs 存储库中。

ipfs files stat <path> - Display file status.

--with-local  bool   - Compute the amount of the dag that is local, and if possible the total size.
--size        bool   - Print only size. Implies '--format=<cumulsize>'. Conflicts with other format options. ```

$ hash="QmPHTrNR9yQYRU4Me4nSG5giZVxb4zTtEe1aZshgByFCFS"
$ ipfs files stat --with-local --size /ipfs/$hash
407624015
Local: 408 MB of 408 MB (100.00%)