Does the DHT.provide(cid)
and DHT.reprovide(cid)
announces to all the near peers only the top-level CID or also all its links?
Example - 1.1MB file:
ipfs add <file> // QmVCnUnL1w553ae5H1NpX6tfn6CkMvdfqbemWqdmSgGYLN
ipfs object get QmVCnUnL1w553ae5H1NpX6tfn6CkMvdfqbemWqdmSgGYLN | jq 1|0 ok 16s
{
"Links": [
{
"Name": "",
"Hash": "QmdCy1sJEpXhggCZkqDeuSqe4sdAiH7aMrPLH2A4YxX2SP",
"Size": 262158
},
{
"Name": "",
"Hash": "QmQau37aEynAKtAmM6EdGFDu4iXAF6Eyzsu9KyZJ8YxL4G",
"Size": 262158
},
{
"Name": "",
"Hash": "QmTrVEozuyzBMfDhB7RK45quu1yJjSBvHooQjeAnwn3Y49",
"Size": 262158
},
{
"Name": "",
"Hash": "QmQQB5TbHy1wHNrwsZ4RiEonfMcaViJEzYWxWys592XzRe",
"Size": 262158
},
{
"Name": "",
"Hash": "QmSyCK88w52vhWxgerd76TPFAxi9AaHFXAxwvNLu6RLX1Y",
"Size": 219444
}
],
"Data": "\b\u0002\u0018ļæ½ļæ½M ļæ½ļæ½\u0010 ļæ½ļæ½\u0010 ļæ½ļæ½\u0010 ļæ½ļæ½\u0010 ļæ½ļæ½\r"
}
When the file is added, and automatically pinned, the node also announces it to the DHT:
wg := sync.WaitGroup{}
for p := range peers {
wg.Add(1)
go func(p peer.ID) {
defer wg.Done()
logger.Debugf("putProvider(%s, %s)", loggableProviderRecordBytes(keyMH), p)
err := dht.sendMessage(ctx, p, mes)
if err != nil {
logger.Debug(err)
}
}(p)
}
wg.Wait()
It seems like it only announces the file CID QmVCnUnL1w553ae5H1NpX6tfn6CkMvdfqbemWqdmSgGYLN
and not its links?
Q1: Does Peer1 announces to DHT the top-level CID QmVCnUnL1w553ae5H1NpX6tfn6CkMvdfqbemWqdmSgGYLN
or also all its links?
Q2: How does it work when Peer2 is searching for this file?
The Peer2 will execute Bitswap
's wantBlocks(QmVCnUnL1w553ae5H1NpX6tfn6CkMvdfqbemWqdmSgGYLN)
(the top-level file CID) via the WantManager
and if Peer1 will answer the request, it will send him the file in the 5 above Blocks
format?
Q3: How does it work when Peer3 happens to have part of the file?
Letās say Peer3 has one of the Blocks QmdCy1sJEpXhggCZkqDeuSqe4sdAiH7aMrPLH2A4YxX2SP
(the first link in the original file) - for whatever random reason.
Can Peer2ās Bitswap fetch the 4 blocks from Peer1 and 1 block from Peer3? Or that will not happen because the Peer3 would have to have the entire file and have announced to DHT the top-level CID QmVCnUnL1w553ae5H1NpX6tfn6CkMvdfqbemWqdmSgGYLN
in the past?