merkle

package
v0.0.0-...-6e19431 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const BlockSize = 1 << 14 // 16KiB

The leaf block size for BitTorrent v2 Merkle trees.

Variables

This section is empty.

Functions

func CompactLayerToSliceHashes

func CompactLayerToSliceHashes(compactLayer string) (hashes [][sha256.Size]byte, err error)

func Log2RoundingUp

func Log2RoundingUp(n uint) (ret uint)

func Root

func Root(hashes [][sha256.Size]byte) [sha256.Size]byte

func RootWithPadHash

func RootWithPadHash(hashes [][sha256.Size]byte, padHash [sha256.Size]byte) [sha256.Size]byte

func RoundUpToPowerOfTwo

func RoundUpToPowerOfTwo(n uint) (ret uint)

Types

type Hash

type Hash struct {
	// contains filtered or unexported fields
}

func NewHash

func NewHash() *Hash

func (*Hash) BlockSize

func (h *Hash) BlockSize() int

func (*Hash) Reset

func (h *Hash) Reset()

func (*Hash) Size

func (h *Hash) Size() int

func (*Hash) Sum

func (h *Hash) Sum(b []byte) []byte

func (*Hash) SumMinLength

func (h *Hash) SumMinLength(b []byte, length int) []byte

Sums by extending with zero hashes for blocks missing to meet the given length. Necessary for piece layers hashes for file tail blocks that don't pad to the piece length.

func (*Hash) Write

func (h *Hash) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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