chunk

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package chunk provides a heap of chunks so that larger in-order chunks can be processed more easily, e.g., for verifying ranged inclusion proofs and batching file writes. For how to implement the heap interface, see: https://pkg.go.dev/container/heap#Interface

Idea to use a heap from: https://github.com/aarongable/ctaudit

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	Start      int64               // index of first leaf in this chunk
	LeafHashes [][sha256.Size]byte // in-order leaf hashes in this chunk
	SANs       []string            // sans of all leaves in this chunk
	Notes      []string            // notes about this chunk, e.g., errors
}

Chunk holds the SANs of a consecutive range of downloaded leaves. The start index and associated leaf hashes are included so that they can be verified.

type ChunkHeap

type ChunkHeap []*Chunk

ChunkHeap is a min-heap of chunks wrt. to start indices. Use TPush() and TPop() to to push/pop chunks without having to worry about type casts.

func (ChunkHeap) Len

func (h ChunkHeap) Len() int

func (ChunkHeap) Less

func (h ChunkHeap) Less(i, j int) bool

func (*ChunkHeap) Pop

func (h *ChunkHeap) Pop() any

func (*ChunkHeap) Push

func (h *ChunkHeap) Push(x any)

func (*ChunkHeap) Sequence

func (h *ChunkHeap) Sequence(start int64) bool

Sequence checks if the next pop would provide a chunk starting at index start. If so, the heap is also re-organized so that the popped chunk will be as large as possible (i.e., in-order chunks are merged to a single chunk).

func (ChunkHeap) Swap

func (h ChunkHeap) Swap(i, j int)

func (*ChunkHeap) TPop

func (h *ChunkHeap) TPop() *Chunk

TPop pops a chunk from the heap

func (*ChunkHeap) TPush

func (h *ChunkHeap) TPush(c *Chunk)

TPush pushes a chunk to the heap

Jump to

Keyboard shortcuts

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