bootstrap

package
v0.2.26-beta.1 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package bootstrap checks for the bootstrap/fallback data update from the spacemesh administrator (a centralized entity controlled by the spacemesh team). This is intended as a short-term solution at the beginning of the network deployment to facilitate recovering from network failures and should be removed once the network is stable.

The updater periodically checks for the latest update from a URL provided by the spacemesh administrator, verifies the data, persists on disk and notifies subscribers of a new update.

Subscribers register by calling `Subscribe()` to receive a channel for the latest update.

Index

Constants

View Source
const (
	DefaultURL = "http://localhost:3000/bootstrap"
	DirName    = "bootstrap"
)

Variables

View Source
var (
	ErrEpochOutOfOrder = errors.New("epoch out of order")
	ErrWrongVersion    = errors.New("wrong schema version")
	ErrInvalidBeacon   = errors.New("invalid beacon")
)

Functions

func PersistFilename

func PersistFilename(dir string, id uint32) string

Types

type Config

type Config struct {
	URL     string `mapstructure:"bootstrap-uri"`
	Version string `mapstructure:"bootstrap-version"`

	DataDir   string
	Interval  time.Duration
	NumToKeep int
}

func DefaultConfig

func DefaultConfig() Config

type EpochData

type EpochData struct {
	Epoch     uint32   `json:"epoch"`
	Beacon    string   `json:"beacon"`
	ActiveSet []string `json:"activeSet"`
}

type EpochOverride

type EpochOverride struct {
	Epoch     types.EpochID
	Beacon    types.Beacon
	ActiveSet []types.ATXID
}

type InnerData

type InnerData struct {
	ID     uint32      `json:"id"`
	Epochs []EpochData `json:"epochs"`
}

type Opt

type Opt func(*Updater)

func WithConfig

func WithConfig(cfg Config) Opt

func WithFilesystem

func WithFilesystem(fs afero.Fs) Opt

func WithHttpClient

func WithHttpClient(c *http.Client) Opt

func WithLogger

func WithLogger(logger log.Log) Opt

type Update

type Update struct {
	Version string    `json:"version"`
	Data    InnerData `json:"data"`
}

type Updater

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

func New

func New(opts ...Opt) *Updater

func (*Updater) Close

func (u *Updater) Close()

func (*Updater) DoIt

func (u *Updater) DoIt(ctx context.Context) error

func (*Updater) Load

func (u *Updater) Load(ctx context.Context) error

func (*Updater) Start

func (u *Updater) Start(ctx context.Context)

func (*Updater) Subscribe

func (u *Updater) Subscribe() chan *VerifiedUpdate

type VerifiedUpdate

type VerifiedUpdate struct {
	Persisted string
	ID        uint32
	Data      []*EpochOverride
}

func (*VerifiedUpdate) MarshalLogObject

func (vd *VerifiedUpdate) MarshalLogObject(encoder log.ObjectEncoder) error

Jump to

Keyboard shortcuts

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