packutil

package
v0.5.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: Apache-2.0, MIT Imports: 12 Imported by: 0

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(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 Min

func Min(i int, i2 int) int

func WriteCarBlock

func WriteCarBlock(writer io.Writer, block blocks.Block) (int64, error)

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

func WriteCarHeader(writer io.Writer, root cid.Cid) ([]byte, error)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL