beacon

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Beacon

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

	// Start begins periodic beacon fetching
	Start(ctx context.Context, interval time.Duration) error

	// Stop halts beacon fetching
	Stop() error
}

Beacon represents a global time source

type DrandBeacon

type DrandBeacon struct {
	// contains filtered or unexported fields
}

DrandBeacon implements the Beacon interface using drand

func NewDrandBeacon

func NewDrandBeacon(endpoint string) (*DrandBeacon, error)

NewDrandBeacon creates a new drand beacon client

func (*DrandBeacon) GetLatestRound

func (d *DrandBeacon) GetLatestRound(ctx context.Context) (*Round, error)

GetLatestRound implements Beacon.GetLatestRound

func (*DrandBeacon) Rounds

func (d *DrandBeacon) Rounds() <-chan *Round

Rounds returns a channel that receives new rounds

func (*DrandBeacon) Start

func (d *DrandBeacon) Start(ctx context.Context, interval time.Duration) error

Start implements Beacon.Start

func (*DrandBeacon) Stop

func (d *DrandBeacon) Stop() error

Stop implements Beacon.Stop

type Round

type Round struct {
	Number     uint64
	Randomness []byte
	Signature  []byte
	Timestamp  time.Time
}

Round represents a single beacon round

Jump to

Keyboard shortcuts

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