fun

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// KeyPerf is a:
	// 3 byte prefix for per-epoch performance keying, followed by:
	// 8 byte big-endian epoch value. (big endian to make db byte-prefix iteration and range-slices follow epoch order)
	//
	// The epoch key represents the boundary when the data became available.
	// I.e. epoch == 2 means that 0 == prev and 1 == current were processed.
	//
	// Values under this key are snappy block-compressed.
	//
	// The value is a []ValidatorPerformance
	KeyPerf string = "prf"
)
View Source
const (
	// KeyTile is a:
	// 3 byte prefix for tile keying, followed by:
	// 1 byte tile type
	// 1 byte zoom.
	// 4 byte big endian X
	// 4 byte big endian Y
	//
	// Note: the X is first, so the DB range iterate can range over epochs at zoom 0.
	//
	// Values under this key are snappy block-compressed.
	//
	// The uncompressed value is 4 squares of tileSize x tileSize, one for R, one for G, B, and A
	// The squares encode column by column.
	//
	// We can encode tiles in with R, G, B, A grouped together separately.
	// And implement the image.Image interface to map back to an image.
	// This way we compress better, and don't store as much alpha-channel data.
	KeyTile string = "til"
)

Variables

This section is empty.

Functions

func OpenDB

func OpenDB(file string, readonly bool, cache int, writeBuf int) (*leveldb.DB, error)

OpenDB opens a level DB.

Filepath to locate db at. Readonly to limit db writes. Cache in megabytes to trade memory for better performance. writeBuf in megabytes to improve writing performance

func StartHttpServer

func StartHttpServer(log log.Logger, listenAddr string, indexData *IndexData, handleImgRequest func(tileType uint8) http.Handler) *http.Server

func UpdatePerf

func UpdatePerf(ctx context.Context, log log.Logger, perf *leveldb.DB, spec *common.Spec, st *era.Store, start, end common.Epoch, workers int) error

func UpdateTiles

func UpdateTiles(log log.Logger, tiles, perf *leveldb.DB, startEpoch, endEpoch common.Epoch) error

Types

type AttestationsLookup

type AttestationsLookup func(slot common.Slot) (phase0.Attestations, error)

type Backend

type Backend interface {
	HandleImageRequest()
}

type BlockLookup

type BlockLookup func(slot uint64, dest common.SSZObj) error

type BlockRootLookup

type BlockRootLookup func(slot common.Slot) (common.Root, error)

type BoundedIndices

type BoundedIndices []common.BoundedIndex

type ImageHandler

type ImageHandler struct {
	Log     log.Logger
	TilesDB *leveldb.DB
}

func (*ImageHandler) HandleImgRequest

func (s *ImageHandler) HandleImgRequest(tileType uint8) http.Handler

type IndexData

type IndexData struct {
	Title string
	API   string
}

IndexData is the Go html template input for index.html

type RandaoLookup

type RandaoLookup func(epoch common.Epoch) ([32]byte, error)

type SlotAttestations

type SlotAttestations struct {
	Slot         common.Slot
	Attestations phase0.Attestations
}

type StateLookup

type StateLookup func(slot uint64, dest common.SSZObj) error

type Tile

type Tile struct {
	R []byte
	G []byte
	B []byte
	A []byte
	// added to x lookups
	OffsetX int
	// added to y lookups
	OffsetY int
	// Shifts x and y by given amount to create zoomed image effect,
	// while really serving the same tile.
	// This is useful to zoom in more than 1:1 pixel definition,
	// enlarging tiles without image scaling artifacts on client side.
	Scale uint8
}

Tile represents an image tile, as stored in the DB. R,G,B,A are slices stored next to eachother, since they compress better individually.

Each color slice encodes column by column first, since correlation is larger per-column, for better compression. I.e. values 0,1,2,3,4...tilesize-1 all correspond to column 0 (X == 0).

func (*Tile) At

func (t *Tile) At(x, y int) color.Color

At returns the color of the pixel at (x, y). At(Bounds().Min.X, Bounds().Min.Y) returns the upper-left pixel of the grid. At(Bounds().Max.X-1, Bounds().Max.Y-1) returns the lower-right one.

func (*Tile) Bounds

func (t *Tile) Bounds() image.Rectangle

Bounds returns the domain for which At can return non-zero color. The bounds do not necessarily contain the point (0, 0).

func (*Tile) ColorModel

func (t *Tile) ColorModel() color.Model

ColorModel returns the Image's color model.

func (*Tile) Opaque

func (t *Tile) Opaque() bool

func (*Tile) RGBAAt

func (t *Tile) RGBAAt(x, y int) color.RGBA

type ValidatorPerformance

type ValidatorPerformance uint32
const (
	// and the next 64 values (6 bits). Always non-zero
	InclusionDistance ValidatorPerformance = 0x00_00_01_00

	InclusionDistanceMask = 0x00_00_ff_00

	// source is always correct, or wouldn't be included on-chain
	TargetCorrect ValidatorPerformance = 0x00_ff_00_00

	// up to 64, or 0xff if unknown
	HeadDistance ValidatorPerformance = 0x01_00_00_00

	ValidatorExists ValidatorPerformance = 0x00_00_00_01
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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