Determine which peer served a given multihash?

If I have multiple nodes pinning a given multihash, and I successfully retrieve it with ‘ipfs cat Qm…’, is it possible to know which peer actually served said multihash?


Peers 1,2,3 pin QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco

I make a request to and it successfully returns

How do I know whether 1,2 or 3 is the peer from which I have retrieved QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco?

From what I understand, you will get the content from the closest peer. So, if someone was on your local network, ie node 3 , you would get the content from them.

I’m working on as webapp to be a search engine for hash based content. It doesn’t host the content ( ipfs does that ). It will be a place where users can post hash + metadata. Something like …my content = username+hash+file details(size, type, date). Users can search database by author, hash, file details and also rating. When you find something you like, you can view it in ( if it’s browser content ) or download/pin it. App will keep track of how many people pin a certain hash and how people rate the file.

This will allow you to quickly browse through huge lists of hashes and filter it in a way that suits you. Not like google where search are manipulated by various factors.

This also gives users the chance to see which other user posted content and how others have verified, rated that content.

Is closest defined in terms of, say, geographic distance? or some other metric?

Because if that were the case it seems like we should be able to calculate the closest peer and assume a link is retrieved from it…which would be very useful in this case

I think it’s geographic but I’m not sure. You’ll have to way for a more knowledgeable answer.

IPFS uses Kademlia routing protocol. Kademlia has devised a XOR matric for calculating the distance between the nodes. It calculates the distance as XOR of the nodeID of the two peers.
Since XOR is symmetric, the distance between the two nodes remains the same, whichever node calculates it.