GT:
Problem:
IPLD allows you to divide the file into blocks of different sizes and bind them differently. As a result, for the same file there can be a lot of variants of trees and, accordingly, hashes.
Decision:
If the file is divided into raw blocks. Into the root block, the hash of the entire file is written as if it were one large raw block. Accordingly, this hash is additionally announced to the network.
The client receiving the root block additionally searches for the source of the entire file by its hash and checks it by hash of the parts in the root block.
If the file has been fully loaded then it is rechecked by its RawLink. If RawLink does not match then the correct RawLink is written to the root block.
Original [RU]:
Проблема:
IPLD позволяет делить файл на блоки разного размера и по разному связывать их. В итоге для одного и того же файла может быть множество вариантов деревьев и соответственно хешей.
Решение:
Если файл делиться на сырые блоки в корневой блок записывается хеш всего файла как если бы это был один большой сырой блок. Соответственно этот хеш дополнительно анонсируется в сеть.
Клиент получив корневой блок дополнительно ищет источники файла целиком по его хешу и проверяет его по хешам частей в корневом блоке.
Если файл был полностью загружен то перепроверяется его RawLink. Если RawLink не совпадает то в корневой блок записывается правильный RawLink.
protocol buffers format
message PBLink {
optional bytes Hash = 1;
optional string Name = 2;
optional uint64 Tsize = 3;
}
message PBNode {
repeated PBLink Links = 2;
optional PBLink RawLink = 3;
optional bytes Data = 1;
}
GT:
RawLink is CIDv1 the whole file as a raw block. It is used to find additional data sources for the file.
Original [RU]:
RawLink это CIDv1 всего файла как сырого блока. Он используется для поиска дополнительных источников данных файла.
GT:
Example:
The first participant publishes the file by selecting the block size of 131072 bytes. And gets a CIDv0 of the root block: QmAAAA...AAAA
Original [RU]:
Пример:
Первый участник публикует файл выбрав размер блока в 131072 байт. И получает CIDv0 корневого блока: QmAAAA...AAAA
{
"Links": [
{
"Name": "",
"Hash": "zb2rhA2A2A2...A2A2A2",
"Size": 131072
},
{
"Name": "",
"Hash": "zb2rhB2B2B2...B2B2B2",
"Size": 131072
},
{
"Name": "",
"Hash": "zb2rhC2C2C2...C2C2C2",
"Size": 131072
},
{
"Name": "",
"Hash": "zb2rhD2D2D2...D2D2D2",
"Size": 131072
},
{
"Name": "",
"Hash": "zb2rhC1C1C1...C1C1C1C1",
"Size": 59029
}
],
"RawLink":{
"Name": "",
"Hash": "zb2rhR0R0R0R0...R0R0R0R0",
"Size": 583317
},
"Data": "\b\u0002\u0018\ufffd\u0343\f ... \ufffd\ufffd\u0003"
}
GT:
The second participant publishes the file by selecting the block size of 262144 bytes. And got a CIDv0 of the root block: QmBBBB...BBBB
Original [RU]:
Второй участник публикует файл выбрав размер блока 262144 байт. И получил CIDv0 корневого блока: QmBBBB...BBBB
{
"Links": [
{
"Name": "",
"Hash": "zb2rhA1A1...A1A1",
"Size": 262144
},
{
"Name": "",
"Hash": "zb2rhB1B1B1...B1B1B1",
"Size": 262144
},
{
"Name": "",
"Hash": "zb2rhC1C1C1...C1C1C1C1",
"Size": 59029
}
],
"RawLink":{
"Name": "",
"Hash": "zb2rhR0R0R0R0...R0R0R0R0",
"Size": 583317
},
"Data": "\b\u0002\u0018\ufffd\u0343\f ... \ufffd\ufffd\u0003"
}
GT:
At both one and the same file which has a CIDv1 zb2rhR0R0R0R0...R0R0R0R0. This CIDv1 is written in RawLink.
The third participant received the QmAAAA...AAAA block and additionally searches the network for the sources of the block zb2rhR0R0R0R0...R0R0R0R0.
He finds the second participant by the CIDv1 zb2rhR0R0R0R0...R0R0R0R0 and asks him for the parts of the block zb2rhR0R0R0R0...R0R0R0R0 which are checked with hashes(CIDv1 Links) in the block QmAAAA ... AAAA.
Original [RU]:
У обоих один и тотже файл который имеет хеш zb2rhR0R0R0R0...R0R0R0R0. Этот хеш записан в RawLink.
Третий участник получил блок QmAAAA...AAAA и дополнительно ищет в сети источники блока zb2rhR0R0R0R0...R0R0R0R0.
Он находит второго участника по хешу zb2rhR0R0R0R0...R0R0R0R0 и запрашивает у него части блока zb2rhR0R0R0R0...R0R0R0R0 которые проверяет хешами(CIDv1 Links) в блоке QmAAAA...AAAA.