【问题标题】:How to check is the given <ipfs_hash> is already fully downloaded or not?如何检查给定的 <ipfs_hash> 是否已经完全下载?
【发布时间】:2021-12-23 23:56:22
【问题描述】:

首先,当我运行 ipfs --offline block stat &lt;ipfs_hash&gt; 时,如果哈希在本地不存在,我会收到以下消息:Error: blockservice: key not found

  • 之后我运行以下命令:ipfs object stat &lt;ipfs_hash&gt; 并在获得有效输出后

  • 我再次运行ipfs --offline block stat &lt;ipfs_hash&gt;,现在它总是返回有效信息(因此不会给出错误),即使没有下载哈希。所以假设如果ipfs --offline block stat &lt;ipfs_hash&gt;给出并且Error消息不相关,那么给定的哈希是本地下载的。

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


我可以执行ipfs refs local | grep &lt;hash&gt; 之类的操作,但我不想继续获取所有哈希值,并且当存在数百个哈希值时它会变慢。

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

【问题讨论】:

    标签: ipfs


    【解决方案1】:

    ipfs files stat --with-local --size &lt;path&gt; 返回请求的 ipfs 哈希的下载百分比。如果它是100.00%,我们可以验证它是否完全下载到本地ipfs repo。

    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%)
    

    【讨论】:

      猜你喜欢
      • 2013-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-03
      • 2014-11-29
      相关资源
      最近更新 更多