chain

package
v2.0.6-testnet Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0, MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BoltTrimmedMetrics = iota + 1
	PostgreSQLMetrics
	MemDBMetrics
	BoltUntrimmedMetrics
)

Metrics values for reporting storage type used. Only append new values. Also, add new values to the DrandStorageBackend metric Help.

Variables

This section is empty.

Functions

func BytesToRound

func BytesToRound(r []byte) uint64

BytesToRound unserializes a round number from bytes (8 bytes fixed length big-endian) to uint64.

func GenesisBeacon

func GenesisBeacon(seed []byte) *common.Beacon

GenesisBeacon returns the first beacon inserted in the chain

func PreviousRequiredFromContext

func PreviousRequiredFromContext(ctx context.Context) bool

func RoundToBytes

func RoundToBytes(r uint64) []byte

RoundToBytes serializes a round number to bytes (8 bytes fixed length big-endian).

func SetPreviousRequiredOnContext

func SetPreviousRequiredOnContext(ctx context.Context) context.Context

Types

type Cursor

type Cursor interface {
	First(context.Context) (*common.Beacon, error)
	Next(context.Context) (*common.Beacon, error)
	Seek(ctx context.Context, round uint64) (*common.Beacon, error)
	Last(context.Context) (*common.Beacon, error)
}

Cursor iterates over items in sorted key order. This starts from the first key/value pair and updates the k/v variables to the next key/value on each iteration.

The loop finishes at the end of the cursor when a nil key is returned.

for k, v := c.First(); k != nil; k, v = c.Next() {
    fmt.Printf("A %s is %s.\n", k, v)
}

type StorageType

type StorageType string

StorageType defines the supported storage engines

const (
	// BoltDB uses the BoltDB engine for storing data
	BoltDB StorageType = "bolt"

	// PostgreSQL uses the PostgreSQL database for storing data
	PostgreSQL StorageType = "postgres"

	// MemDB uses the in-memory database to store data
	MemDB StorageType = "memdb"
)

Storage engine types

type Store

type Store interface {
	Len(context.Context) (int, error)
	Put(context.Context, *common.Beacon) error
	Last(context.Context) (*common.Beacon, error)
	Get(ctx context.Context, round uint64) (*common.Beacon, error)
	Cursor(context.Context, func(context.Context, Cursor) error) error
	Close() error
	Del(ctx context.Context, round uint64) error
	SaveTo(ctx context.Context, w io.Writer) error
}

Store is an interface to store Beacons packets where they can also be retrieved to be delivered to end clients.

Directories

Path Synopsis
postgresdb
database
Package database provides support for access the database.
Package database provides support for access the database.
schema
Package schema helps to keep the database up to date with schema.
Package schema helps to keep the database up to date with schema.

Jump to

Keyboard shortcuts

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