Documentation ¶
Index ¶
Constants ¶
View Source
const ChunkSize int64 = 1 << 20
View Source
const NumLinkPerNode = 1024
Variables ¶
View Source
var EmptyCarHeader, _ = util.GenerateCarHeader(EmptyFileCid)
View Source
var EmptyFileCid = cid.NewCidV1(cid.Raw, util2.Hash([]byte("")))
View Source
var EmptyFileVarint = varint.ToUvarint(uint64(len(EmptyFileCid.Bytes())))
Functions ¶
func AssembleFileFromLinks ¶
func AssembleFileFromLinks(links []format.Link) ([]blocks.Block, *merkledag.ProtoNode, error)
AssembleFileFromLinks constructs a MerkleDAG from a list of links. It organizes the links into a tree structure where each internal node can have up to NumLinkPerNode children. This function assembles the DAG and returns the blocks that make up the DAG and the root node of the DAG.
Parameters:
- links: An array of format.Link objects representing the links to the content that will be part of the MerkleDAG.
Returns:
- []blocks.Block: A slice of Block objects representing the blocks of the constructed MerkleDAG. Each block contains a part of the overall data.
- *merkledag.ProtoNode: The root node of the created MerkleDAG. This node provides a starting point to navigate through the rest of the DAG.
- error: An error that can occur during the MerkleDAG creation process, or nil if the operation was successful.
func WriteCarBlock ¶
WriteCarBlock writes a block in CAR (Content Addressable aRchive) format to a given io.Writer.
Parameters:
- writer: An io.Writer to which the CAR-formatted block will be written.
- block: A blocks.Block instance representing the data to be written.
Returns:
- int64: The number of bytes written to the writer.
- error: An error that can occur during the write process, or nil if the write was successful.
func WriteCarHeader ¶
WriteCarHeader writes the CAR (Content Addressable aRchive) format header to a given io.Writer.
Parameters:
- writer: An io.Writer to which the CAR header will be written.
- root: The root CID (Content Identifier) for the CAR file.
Returns:
- []byte: The byte representation of the CAR header.
- error: An error that can occur during the write process, or nil if the write was successful.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.