checkpoint

package
v0.3.9-beta.1 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SchemaVersion = "https://spacemesh.io/checkpoint.schema.json.1.0"
)

Variables

View Source
var Schema string

Functions

func CopyFile

func CopyFile(fs afero.Fs, src, dst string) error

func Generate

func Generate(ctx context.Context, fs afero.Fs, db *sql.Database, dataDir string, snapshot types.LayerID) error

func ParseRestoreLayer

func ParseRestoreLayer(fname string) (types.LayerID, error)

ParseRestoreLayer parses the restore layer from the filename. only used in systests when RecoverFromDefaultDir is true. DO NOT USE in production as inferring metadata from filename is not robust and error-prone.

func ReadCheckpointAndDie

func ReadCheckpointAndDie(ctx context.Context, logger log.Log, dataDir, uri string, restore types.LayerID) error

ReadCheckpointAndDie copies the checkpoint file from uri and panic to restart the node and recover from the checkpoint data just copied. only used in systests. only has effect when RecoverFromDefaultDir is true.

func Recover

func Recover(
	ctx context.Context,
	logger log.Log,
	fs afero.Fs,
	cfg *RecoverConfig,
	nodeID types.NodeID,
	uri string,
	restore types.LayerID,
) error

func RecoverWithDb

func RecoverWithDb(
	ctx context.Context,
	logger log.Log,
	db *sql.Database,
	fs afero.Fs,
	cfg *RecoverConfig,
	nodeID types.NodeID,
	uri string,
	restore types.LayerID,
) (*sql.Database, error)

func RecoveryDir

func RecoveryDir(dataDir string) string

func RecoveryFilename

func RecoveryFilename(dataDir, base string, restore types.LayerID) string

func SelfCheckpointFilename

func SelfCheckpointFilename(dataDir string, snapshot types.LayerID) string

func ValidateSchema

func ValidateSchema(data []byte) error

Types

type Account

type Account struct {
	Address  []byte `json:"address"`
	Balance  uint64 `json:"balance"`
	Nonce    uint64 `json:"nonce"`
	Template []byte `json:"template"`
	State    []byte `json:"state"`
}

type Checkpoint

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

type Config

type Config struct {
	Uri     string `mapstructure:"recovery-uri"`
	Restore uint32 `mapstructure:"recovery-layer"`

	// set to false if atxs are not compatible before and after the checkpoint recovery.
	PreserveOwnAtx bool

	// only set for systests. recovery from file in $DataDir/recovery
	RecoverFromDefaultDir bool
}

func DefaultConfig

func DefaultConfig() Config

type InnerData

type InnerData struct {
	CheckpointId string     `json:"id"`
	Atxs         []ShortAtx `json:"atxs"`
	Accounts     []Account  `json:"accounts"`
}

type RecoverConfig

type RecoverConfig struct {
	GoldenAtx      types.ATXID
	DataDir        string
	DbFile         string
	PreserveOwnAtx bool
}

type RecoveryFile

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

func NewRecoveryFile

func NewRecoveryFile(fs afero.Fs, path string) (*RecoveryFile, error)

func (*RecoveryFile) Copy

func (rf *RecoveryFile) Copy(fs afero.Fs, src io.Reader) error

func (*RecoveryFile) Save

func (rf *RecoveryFile) Save(fs afero.Fs) error

type ShortAtx

type ShortAtx struct {
	ID             []byte `json:"id"`
	Epoch          uint32 `json:"epoch"`
	CommitmentAtx  []byte `json:"commitmentAtx"`
	VrfNonce       uint64 `json:"vrfNonce"`
	NumUnits       uint32 `json:"numUnits"`
	BaseTickHeight uint64 `json:"baseTickHeight"`
	TickCount      uint64 `json:"tickCount"`
	PublicKey      []byte `json:"publicKey"`
	Sequence       uint64 `json:"sequence"`
	Coinbase       []byte `json:"coinbase"`
}

Jump to

Keyboard shortcuts

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