Expand description
The IPFS data model, minimally: multihashes (sha2-256 only), CIDv0 and CIDv1 in binary and
text (base58btc, and base32 as b…), the raw and dag-pb codecs, and UnixFS nodes.
A block’s CID is always computed here from its bytes. Nothing a peer or the model says about a block’s identity is taken on trust: a block is sent, or reported, only when its bytes hash to the CID it is sent or reported under.
Protobuf nesting is fixed by the schema (PBNode → PBLink, PBNode.Data → UnixFS Data); no decoder here recurses, so a peer cannot buy stack depth.
Structs§
- Cid
- A content identifier: version, codec and a sha2-256 digest. Other hash functions are not representable, so a CID naming one is refused at parse time.
- Described
- What a block looks like to whoever receives it: its codec, and for dag-pb its UnixFS meaning and links.
- Link
- A dag-pb link: the child’s CID, its name in a directory, and the size of its subtree.
- PbNode
- A decoded dag-pb node.
- UnixFs
- What a UnixFS node says about itself.
Constants§
- DAG_PB
- Multicodec
dag-pb: a protobuf PBNode, the codec UnixFS is written in. - MAX_
BLOCK - A block is at most this long (Bitswap’s own limit, which Kubo enforces too).
- MAX_
CID_ TEXT - A CID in text is at most this long; a sha2-256 CIDv1 in base32 is 59 characters.
- MAX_
LINKS - Links one dag-pb node may carry before it is refused (Kubo writes at most 174 per file node and 1024-ish per directory shard).
- RAW
- Multicodec
raw: the block is the bytes. - SHA2_
256 - Multihash
sha2-256, 32-byte digests.
Functions§
- base32_
decode - base32_
encode - RFC 4648 base32, lower case, no padding (multibase
b). - cids_
for_ digest - Every CID text a sha2-256 digest can stand for, in the two codecs NetGet knows: what a DHT key (a bare multihash) may mean.
- codec_
name - Why a CID is not one NetGet can serve or verify.
- decode_
pb_ node - decode_
unixfs - describe
- encode_
pb_ node - The canonical dag-pb encoding: every link (field 2) before the data (field 1).
- encode_
unixfs - UnixFS
Data: Type, Data, filesize, blocksizes, in field order as go-unixfs writes them. - multihash_
bytes - parse_
multihash - A multihash’s digest, refusing every function but sha2-256 with 32-byte output.
- sha256
sha2-256multihash ofdata: the 34 bytes0x12 0x20 ‖ digest.- unixfs_
file_ block - A single-block UnixFS file holding
content, asipfs addwrites a file no larger than its chunk size when it does not use raw leaves.