chunks

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: MIT Imports: 3 Imported by: 10

Documentation

Overview

Package chunks provides the basic structure for a pair of the weak and strong checksums. Since this is fairly widely used, splitting this out breaks a number of possible circular dependencies

Index

Constants

This section is empty.

Variables

View Source
var ErrPartialChecksum = errors.New("Reader length was not a multiple of the checksums")

Functions

This section is empty.

Types

type ChunkChecksum

type ChunkChecksum struct {
	// an offset in terms of chunk count
	ChunkOffset uint
	// the size of the block
	Size           int64
	WeakChecksum   []byte
	StrongChecksum []byte
}

For a given Block, the Weak & Strong hashes, and the offset This structure is only used to generate the index of reference files, since computing the strong checksum is not done when comparing unless the weak checksum matches

func LoadChecksumsFromReader

func LoadChecksumsFromReader(
	r io.Reader,
	weakHashSize int,
	strongHashSize int,
) ([]ChunkChecksum, error)

Loads chunks from a reader, assuming alternating weak then strong hashes

func (ChunkChecksum) Match

func (chunk ChunkChecksum) Match(other ChunkChecksum) bool

compares a checksum to another based on the checksums, not the offset

type StrongChecksumGetter

type StrongChecksumGetter []ChunkChecksum

satisfies filechecksum.ChecksumLookup

func (StrongChecksumGetter) GetStrongChecksumForBlock

func (s StrongChecksumGetter) GetStrongChecksumForBlock(blockID int) []byte

Jump to

Keyboard shortcuts

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