0

I have this snippet here from https://js.ipfs.io/:

const node = await IPFS.create()

const stream = node.cat('QmPChd2hVbrJ6bfo3WBcTW4iZnpHm8TEzWkLHmLpXhF68A')
let data = ''

for await (const chunk of stream) {
  // chunks of data are returned as a Buffer, convert it back to a string
  data += chunk.toString()
}

console.log(data)

It prints fine and I can the data.

My questions:

  • Where exactly is this data corresponding to the hash stored? Is it possible to know what peers are storing this data?

  • What happens if I want to change the data? Do I have to generate a new hash every time?

nz_21
  • 6,140
  • 7
  • 34
  • 80

1 Answers1

0

If your node has a copy of the data, it'll be stored in your local repo.

If it does not, it'll use bitswap to try to fetch it from connected peers.

You can find out which peers have the data by querying the DHT using ipfs.dht.findProvs.

The 'QmPCh..' string is a content identifier so if the data changes, so will the hash.

achingbrain
  • 191
  • 2