shared

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: Apache-2.0 Imports: 1 Imported by: 2

Documentation

Index

Constants

View Source
const (
	NodeSize = 32
)

Variables

This section is empty.

Functions

func RootHeightFromWidth

func RootHeightFromWidth(width uint64) uint

Types

type CacheReader

type CacheReader interface {
	Layers() map[uint]LayerReadWriter
	GetLayerReader(layerHeight uint) LayerReader
	GetHashFunc() HashFunc
	GetLayerFactory() LayerFactory
	GetCachingPolicy() CachingPolicy
}

type CacheWriter

type CacheWriter interface {
	SetLayer(layerHeight uint, rw LayerReadWriter)
	GetLayerWriter(layerHeight uint) (LayerWriter, error)
	SetHash(hashFunc HashFunc)
	GetReader() (CacheReader, error)
}

type CachingPolicy

type CachingPolicy func(layerHeight uint) (shouldCacheLayer bool)

type HashFunc

type HashFunc func(buf, lChild, rChild []byte) []byte

type LayerFactory

type LayerFactory func(layerHeight uint) (LayerReadWriter, error)

type LayerReadWriter

type LayerReadWriter interface {
	Seek(index uint64) error
	ReadNext() ([]byte, error)
	Width() (uint64, error)
	Append(p []byte) (n int, err error)
	Flush() error
	Close() error
}

LayerReadWriter is a combined reader-writer. Note that the Seek() method only belongs to the LayerReader interface and does not affect the LayerWriter.

type LayerReader

type LayerReader interface {
	Seek(index uint64) error
	ReadNext() ([]byte, error)
	Width() (uint64, error)
	Close() error
}

type LayerWriter

type LayerWriter interface {
	Append(p []byte) (n int, err error)
	Flush() error
	Close() error
}

Jump to

Keyboard shortcuts

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