limits

package
v0.75.8-fix.1 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

README

Network limits

This package allow the configuration of network wide limits / restriction. This restriction are set as part of the genesis block and will be valid for the whole duration of the network. The only way to update them would be to start a brand new network with a new set of these settings.

Here's the list of the settings available:

  • propose_market_enabled: type=boolean, are markets proposal allowed
  • propose_asset_enabled: type=boolean, are assets proposal allowed
  • propose_market_enabled_from: type=date, optional, from when markets proposal allowed
  • propose_asset_enabled_from: type=date, optional, from when assets proposal allowed

All dates are to be specified in the RFC3339 format, any invalid date would cause the genesis state to be invalid therefore the network would stop straight away.

For each setting, the boolean value have the priority to the date, this means that if both a boolean value and date are specified but also the boolean value is false, then the given setting will never be enabled.

Example settings:

{
	"app_state": {
		"network_limits": {
			"propose_market_enabled": true, // market proposal enabled
			"popose_asset_enabled": false, // asset proposal disabled forever
			"propose_market_enabled_from": "2021-12-31T23:59:59Z" // this is in UTC timezone, market proposal will be enabled at this date
			// propose_asset_enabled_from is omitted
		}
	}
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoLimitsGenesisState = errors.New("no limits genesis state")

Functions

This section is empty.

Types

type Broker

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

type Config

type Config struct {
	// logging level
	Level encoding.LogLevel
}

func NewDefaultConfig

func NewDefaultConfig() Config

NewDefaultConfig creates an instance of the package specific configuration.

type Engine

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

func New

func New(log *logging.Logger, cfg Config, tm TimeService, broker Broker) *Engine

func (*Engine) CanProposeAsset

func (e *Engine) CanProposeAsset() bool

func (*Engine) CanProposeMarket

func (e *Engine) CanProposeMarket() bool

func (*Engine) CanProposePerpsMarket added in v0.73.0

func (e *Engine) CanProposePerpsMarket() bool

func (*Engine) CanProposeSpotMarket added in v0.73.0

func (e *Engine) CanProposeSpotMarket() bool

func (*Engine) CanTrade

func (e *Engine) CanTrade() bool

func (*Engine) GetState

func (e *Engine) GetState(k string) ([]byte, []types.StateProvider, error)

func (*Engine) Keys

func (e *Engine) Keys() []string

func (*Engine) LoadState

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

func (*Engine) Namespace

func (e *Engine) Namespace() types.SnapshotNamespace

func (*Engine) OnLimitsProposeAssetEnabledFromUpdate

func (e *Engine) OnLimitsProposeAssetEnabledFromUpdate(ctx context.Context, date string) error

func (*Engine) OnLimitsProposeMarketEnabledFromUpdate

func (e *Engine) OnLimitsProposeMarketEnabledFromUpdate(ctx context.Context, date string) error

func (*Engine) OnLimitsProposePerpsMarketEnabledFromUpdate added in v0.73.0

func (e *Engine) OnLimitsProposePerpsMarketEnabledFromUpdate(ctx context.Context, enabled int64) error

func (*Engine) OnLimitsProposeSpotMarketEnabledFromUpdate added in v0.73.0

func (e *Engine) OnLimitsProposeSpotMarketEnabledFromUpdate(ctx context.Context, enabled int64) error

func (*Engine) OnTick

func (e *Engine) OnTick(ctx context.Context, t time.Time)

func (*Engine) Stopped

func (e *Engine) Stopped() bool

func (*Engine) UponGenesis

func (e *Engine) UponGenesis(ctx context.Context, rawState []byte) (err error)

UponGenesis load the limits from the genesis state.

type GenesisState

type GenesisState struct {
	ProposeMarketEnabled bool `json:"propose_market_enabled"`
	ProposeAssetEnabled  bool `json:"propose_asset_enabled"`
}

func DefaultGenesisState

func DefaultGenesisState() GenesisState

func LoadGenesisState

func LoadGenesisState(bytes []byte) (*GenesisState, error)

type TimeService

type TimeService interface {
	GetTimeNow() time.Time
}

TimeService provide the time of the vega node using the tm time.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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