2 IPFS nodes communicating

I want to test 2 IPFS nodes communicating between each other, each running under different ports

Node 1:

ipfs --api=/ip4/127.0.0.1/tcp/5001 config show

“Path”: “/Users/llukac/.ipfs_1/datastore”,

Node 2:

ipfs --api=/ip4/127.0.0.1/tcp/5002 config show

“Path”: “/Users/llukac/.ipfs_2/datastore”

Through the Node 1 Web UI: 5001 I added a simple test file with hash: QmbjELNZKW1QtkJZsFMCi65mLaw198Z2ret45WbuM4oZPQ

Through the Node 2 Web UI: 5002 I am making sure this file doesn’t exist:

When I execute IPFS cat using the TCP IP of Node 1:

ipfs --api=/ip4/127.0.0.1/tcp/5001 cat QmbjELNZKW1QtkJZsFMCi65mLaw198Z2ret45WbuM4oZPQ

Output:

ipfs111

That’s expected…

My question is, how is possible that Node 2 is also able to retrieve the file??? How did Node 2, resolved Node 1 hash?

ipfs --api=/ip4/127.0.0.1/tcp/5002 cat QmbjELNZKW1QtkJZsFMCi65mLaw198Z2ret45WbuM4oZPQ

Output:

ipfs111

According to UI, 0 peers connected, the gateways are under different ports as well… hm

Thx

That’s an older version of the web UI, but I’m pretty sure all that’s showing is pinned files – not all files that are cached.

The two nodes are probably connected to each other, or might be connected through a relay depending on which version of IPFS you’re using; I don’t remember off the top of my head when the ability to connect through relays was added, but I don’t think it’s always been a feature.

At least on my laptop, the webUI always shows 0 peers connected from the start and takes a while to catch up with how many peers I’m actually connected to.

If you’re on linux you can see how many peers are connected from the command line using something like ipfs swarm peers | wc -l.

You are right @leerspace! 250 peers. Grepping for localhost have shown the 5001 peer.

ipfs --api=/ip4/127.0.0.1/tcp/5002 swarm peers|grep 127

/ip4/127.0.0.1/tcp/4001/ipfs/QmZ2E2ZxVQGJsv9L9LFWdsYhAR4gKcM9MW6bSFH6z6RxgY

… And yes, it’s an old version of IPFS, needs an update.

Thx

1 Like