Are Peer Links supported?

Hi,

The white paper mentions Peer Links:

Peer Links.
As encouraged by SFS, users can link other users’ Objects directly into their own Objects (namespace, home, etc). This has the benefit of also creating a web of trust (and supports the old Certificate Authority model):

# Alice links to Bob
ipfs link /[alice-pk-hash]/friends/bob /[bob-pk-hash]

Is this implemented? If not, can this be emulated somehow by “manually” creating objects that point to other objects so that ipfs cat /ipns/<alice-pk-hash>/friends/bob/bobsfile has the same output as ipfs cat /ipns/<bob-pk-hash>/bobsfile?

I assume this is possible with the MFS. Create a folder like ipfs files mkdir /MFSfolder, then add files to your node with ipfs add /LocalPath/to/file, copy them to the folder ipfs files cp /ipfs/<hash> /MFSfolder/filename. Or alternatively, add a full directory with ipfs add -r /LocalPath/to/directory, then copy that to the MFS: ipfs files cp /ipfs/<folderhash> /MFSfolder

You can already publish that folder to the ipns; get the parent hash for the publish command with: ipfs files stat --hash /MFSfolder

But you can also add external objects, which don’t originate from your node, to that folder, i.e. with ipfs files cp /ipfs/<ExternalHash> /folder/filename

However, I’m not exactly sure. I vaguely remember that if you copy external hashes to your MFS, the files themselves are not downloaded and pinned to your node, which is why you can copy references to petabytes of data into your MFS without actually moving the data itself. (But I might be wrong.)

2 Likes

Ah that sounds great, I’m gonna give it a try. MFS stands for Mounted File System? Meaning the disk where the node runs? Thanks @JayBrown!

“Mutable File System”, the one within your node—no mounting necessary. I’ve read the abbreviations “MFS” somewhere, but I don’t know if that’s official. :slight_smile:

Here they’re calling it “unixfs”: https://ipfs.io/docs/commands/#ipfs-files
Later on: “local mutable namespace” and “mfs”.

In other places it’s mentioned under “Files API”.

It’s just like hacking around in a *nix filesystem, but the commands are still rudimentary. I have a topic with feature ideas to enhance the Files API: IPFS files API: plans for additional commands?

2 Likes

Awesome! Now i know why I couldn’t find what mfs stands for :slight_smile:

I just tried this remote-copy-to-MFS myself with ipfs files cp /ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D /test, but as soon as I try to list the contents of that directory (and its subdirectories), my node actually caches the objects: after manually listing all subdirectories, I tested ipfs cat on some of the objects with my node/daemon offline, and for sure, the content was there on my node, whereas I originally thought that you were just adding references to remote objects incl. the fs structure, directory tree etc.)

So here’s my question to someone who can answer: isn’t this method supposed to leave the actual contents out of it, away from my node, until I choose to manually cat/read or pin it?

So here’s my question to someone who can answer: isn’t this method supposed to leave the actual contents out of it, away from my node, until I choose to manually cat/read or pin it?

I’m not that familiar with this interface but it looks like it downloads the root node of each child when listing the directory. For large files, this node will just contain the list of blocks and some metadata. For small files, this will be the entire file.

(disclaimer, I didn’t write the code, this comment is based on my reading of it).

1 Like

When I do that I get:

$ ipfs files mkdir /test
$ ipfs files cp /ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D /test
Error: directory already has entry by that name
$ ipfs files ls /test
# nothing, lets try with trailing slash
$ ipfs files cp /ipfs/QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D /test/
$ ipfs files ls /test
QmTkzDwWqPbnAh5YiV5VwcTLnGdwSNsNTn2aDxdXBFca7D

@JayBrown did you do something else than what I did here?

Never mind, I created the directory /test beforehand, that doesn’t work…

Right. If you files cp a directory, you need to create a new directory in the MFS. If the target directory already exists, you need to files cp the source directory’s contents into the target.

1 Like