epochtime

package
v0.75.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

README

EpochTime

This service is responsible for sending out event bus messages when Vega leaves or enters a new epoch. It also has support for clients subscribing to updates when the epoch changes.

The length of an epoch is defined by the network parameter ValidatorsEpochLength

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broker

type Broker interface {
	Send(e events.Event)
}

type Config

type Config struct {
	Level encoding.LogLevel `long:"log-level"`
}

Config represent the configuration of vegatime service.

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration, given a pointer to a logger instance to be used for logging within the package.

type Svc

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

Svc represents the Service managing epoch inside Vega.

func NewService

func NewService(l *logging.Logger, conf Config, broker Broker) *Svc

NewService instantiates a new epochtime service.

func (*Svc) Checkpoint

func (s *Svc) Checkpoint() ([]byte, error)

func (*Svc) GetState

func (s *Svc) GetState(k string) ([]byte, []types.StateProvider, error)

func (*Svc) Keys

func (s *Svc) Keys() []string

func (*Svc) Load

func (s *Svc) Load(ctx context.Context, data []byte) error

func (*Svc) LoadState

func (s *Svc) LoadState(ctx context.Context, payload *types.Payload) ([]types.StateProvider, error)

func (*Svc) Name

func (*Svc) Name() types.CheckpointName

func (*Svc) Namespace

func (s *Svc) Namespace() types.SnapshotNamespace

func (*Svc) NotifyOnEpoch

func (s *Svc) NotifyOnEpoch(f func(context.Context, types.Epoch), r func(context.Context, types.Epoch))

NotifyOnEpoch allows other services to register 2 callback functions. The first will be called once we enter or leave a new epoch, and the second will be called when the epoch service has been restored from a snapshot.

func (*Svc) OnBlockEnd

func (s *Svc) OnBlockEnd(ctx context.Context)

OnBlockEnd handles a callback from the abci when the block ends.

func (*Svc) OnEpochLengthUpdate

func (s *Svc) OnEpochLengthUpdate(ctx context.Context, l time.Duration) error

func (*Svc) OnTick

func (s *Svc) OnTick(ctx context.Context, t time.Time)

NB: An epoch is ended when the first block that exceeds the expiry of the current epoch ends. As onTick is called from onBlockStart - to make epoch continuous and avoid no man's epoch - once we get the first block past expiry we mark get ready to end the epoch. Once we get the on block end callback we're setting the flag to be ready to start a new block on the next onTick (i.e. preceding the beginning of the next block). Once we get the next block's on tick we close the epoch and notify on its end and start a new epoch (with incremented sequence) and notify about it.

func (*Svc) ReloadConf

func (s *Svc) ReloadConf(conf Config)

ReloadConf reload the configuration for the epochtime service.

func (*Svc) Stopped

func (s *Svc) Stopped() bool

Jump to

Keyboard shortcuts

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