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 ¶
var ErrPartialChecksum = errors.New("Reader length was not a multiple of the checksums")
Functions ¶
func TransformToInternalRepresentation ¶
Required for zsync legacy support
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 LoadChecksumsFromReaderLegacy ¶
func LoadChecksumsFromReaderLegacy( r io.Reader, weakHashSize int, strongHashSize int, ) ([]ChunkChecksum, error)
Loads chunks from a sources, assuming alternating weak then strong hashes This function attempts to be compatible with the original zsync implementation therefore the following assumptions are made: - weak checksums are stored in Little Endian notation - only first <strongHashSize> bytes of the strong checksum are provided
func (ChunkChecksum) Match ¶
func (chunk ChunkChecksum) Match(other ChunkChecksum) bool
compares a checksum to another based on the checksums, not the offset
type ChunkInfo ¶
type ChunkInfo struct { Size int64 Source io.ReadSeeker SourceOffset int64 TargetOffset int64 }
type FileChunksMapper ¶ added in v0.1.3
type FileChunksMapper struct {
// contains filtered or unexported fields
}
func NewFileChunksMapper ¶ added in v0.1.3
func NewFileChunksMapper(fileSize int64) *FileChunksMapper
func (*FileChunksMapper) Add ¶ added in v0.1.3
func (mapper *FileChunksMapper) Add(chunk ChunkInfo)
func (*FileChunksMapper) FillChunksMap ¶ added in v0.1.3
func (mapper *FileChunksMapper) FillChunksMap(chunkChannel <-chan ChunkInfo)
func (*FileChunksMapper) GetMappedChunks ¶ added in v0.1.3
func (mapper *FileChunksMapper) GetMappedChunks() []ChunkInfo
func (*FileChunksMapper) GetMissingChunks ¶ added in v0.1.3
func (mapper *FileChunksMapper) GetMissingChunks() []ChunkInfo
type StrongChecksumGetter ¶
type StrongChecksumGetter []ChunkChecksum
satisfies filechecksum.ChecksumLookup
func (StrongChecksumGetter) GetStrongChecksumForBlock ¶
func (s StrongChecksumGetter) GetStrongChecksumForBlock(blockID int) []byte