Go-ipfs: How can I get the hash of files and folders without giving data to peers online?

Created on 29 Nov 2016  路  3Comments  路  Source: ipfs/go-ipfs

ipfs add command gets me the hash, but it also makes the data available to the peers online.
For testing purpose, while building apps, I need the hash code without making it available to peers.
IPFS allows pin and unpin for pinning objects to local storage. ipfs repo gc remove objects that are not pinned in order to reclaim hard disk space.
But I am unable to understand how it works.
If an object is unpinned, will the data be available to peers?
Also if I download a new file from other peers using a hash, will it get automatically pinned to the local storage?

Most helpful comment

ipfs add -n will give you a hash without making it available.

Pins simply prevent hashes from being reaped by the garbage collector, if you unpin a hash it will still be available until it is reaped. You can force that with ipfs repo gc to clean up all unpinned hashes and I beleive you can remove specific hashes only with ipfs block rm. Once reaped they're no longer available from your node.

if I download a new file from other peers using a hash, will it get automatically pinned to the local storage?

It won't be automatically pinned but it will be in your local storage.

All 3 comments

ipfs add -n will give you a hash without making it available.

Pins simply prevent hashes from being reaped by the garbage collector, if you unpin a hash it will still be available until it is reaped. You can force that with ipfs repo gc to clean up all unpinned hashes and I beleive you can remove specific hashes only with ipfs block rm. Once reaped they're no longer available from your node.

if I download a new file from other peers using a hash, will it get automatically pinned to the local storage?

It won't be automatically pinned but it will be in your local storage.

If a file is already added and you subsequently do add -n will it cause it to stop being provided?

@cpacia no. It will not remove anything from the datastore, it merely just avoids writing to it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

slrslr picture slrslr  路  3Comments

funkyfuture picture funkyfuture  路  3Comments

whyrusleeping picture whyrusleeping  路  4Comments

zignig picture zignig  路  3Comments

jonchoi picture jonchoi  路  3Comments