beacon

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package beacon provides integration with drand for global time anchoring

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfig = fmt.Errorf("invalid beacon configuration")

ErrInvalidConfig indicates the beacon configuration is invalid

Functions

This section is empty.

Types

type Beacon

type Beacon interface {
	// GetLatestRound fetches the latest beacon round
	GetLatestRound(ctx context.Context) (*Round, error)

	// GetRound fetches a specific beacon round
	GetRound(ctx context.Context, round uint64) (*Round, error)

	// Start begins fetching rounds at the specified interval
	Start(ctx context.Context, interval time.Duration) error

	// Stop stops fetching rounds
	Stop() error

	// Subscribe returns a channel that receives new rounds
	Subscribe() (<-chan *Round, error)
}

Beacon represents a drand beacon client

func NewBeacon

func NewBeacon(cfg Config) (Beacon, error)

NewBeacon creates a new drand beacon client

type Config

type Config struct {
	// URL is the drand HTTP endpoint
	URL string

	// ChainHash is the hash of the drand chain info
	ChainHash []byte

	// PublicKey is the drand group public key
	PublicKey []byte

	// Period is the duration between rounds
	Period time.Duration
}

Config represents beacon configuration

type Round

type Round struct {
	// Number is the round number
	Number uint64

	// Randomness is the random bytes produced by drand
	Randomness []byte

	// Signature is the threshold signature of the round
	Signature []byte

	// Timestamp is when this round was created
	Timestamp time.Time
}

Round represents a drand beacon round

Jump to

Keyboard shortcuts

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