api

package
v0.54.1-nocontractcheck Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSignature           = errors.New("invalid signature")
	ErrSubmitTxCommitDisabled     = errors.New("broadcast_tx_commit is disabled")
	ErrUnknownSubmitTxRequestType = errors.New("invalid broadcast_tx type")
)
View Source
var (
	// ErrChainNotConnected signals to the user that he cannot access a given endpoint
	// which require the chain, but the chain is actually offline.
	ErrChainNotConnected = errors.New("chain not connected")
	// ErrChannelClosed signals that the channel streaming data is closed.
	ErrChannelClosed = errors.New("channel closed")
	// ErrEmptyMissingMarketID signals to the caller that the request expected a
	// market id but the field is missing or empty.
	ErrEmptyMissingMarketID = errors.New("empty or missing market ID")
	// ErrEmptyMissingOrderID signals to the caller that the request expected an
	// order id but the field is missing or empty.
	ErrEmptyMissingOrderID = errors.New("empty or missing order ID")
	// ErrEmptyMissingOrderReference signals to the caller that the request expected an
	// order reference but the field is missing or empty.
	ErrEmptyMissingOrderReference = errors.New("empty or missing order reference")
	// ErrEmptyMissingPartyID signals to the caller that the request expected a
	// party id but the field is missing or empty.
	ErrEmptyMissingPartyID = errors.New("empty or missing party ID")
	// ErrEmptyMissingSinceTimestamp signals to the caller that the request expected a
	// timestamp but the field is missing or empty.
	ErrEmptyMissingSinceTimestamp = errors.New("empty or missing since-timestamp")
	// ErrServerShutdown signals to the client that the server  is shutting down.
	ErrServerShutdown = errors.New("server shutdown")
	// ErrStreamClosed signals to the users that the grpc stream is closing.
	ErrStreamClosed = errors.New("stream closed")
	// ErrStreamInternal signals to the users that the grpc stream has an internal problem.
	ErrStreamInternal = errors.New("internal stream failure")
	// ErrNotMapped is when an error cannot be found in the current error map/lookup table.
	ErrNotMapped = errors.New("error not found in error lookup table")
	// ErrInvalidMarketID signals that the market ID does not exists.
	ErrInvalidMarketID = errors.New("invalid market ID")
	// ErrMissingOrder signals that the actual payload is expected to contains an order.
	ErrMissingOrder = errors.New("missing order in request payload")
	// ErrMissingPartyID signals that the payload is expected to contain a party id.
	ErrMissingPartyID = errors.New("missing party id")
	// ErrMalformedRequest signals that the request was malformed.
	ErrMalformedRequest = errors.New("malformed request")
	// ErrMissingAsset signals that an asset was required but not specified.
	ErrMissingAsset = errors.New("missing asset")
	// ErrSubmitOrder is returned when submitting an order fails for some reason.
	ErrSubmitOrder = errors.New("submit order failure")
	// ErrAmendOrder is returned when amending an order fails for some reason.
	ErrAmendOrder = errors.New("amend order failure")
	// ErrCancelOrder is returned when cancelling an order fails for some reason.
	ErrCancelOrder = errors.New("cancel order failure")
	// OrderService...
	ErrOrderServiceGetByMarket      = errors.New("failed to get orders for market")
	ErrOrderServiceGetByMarketAndID = errors.New("failed to get orders for market and ID")
	ErrOrderServiceGetByParty       = errors.New("failed to get orders for party")
	ErrOrderServiceGetByReference   = errors.New("failed to get orders for reference")
	ErrMissingOrderIDParameter      = errors.New("missing orderID parameter")
	ErrOrderNotFound                = errors.New("order not found")
	// TradeService...
	ErrTradeServiceGetByParty          = errors.New("failed to get trades for party")
	ErrTradeServiceGetByMarket         = errors.New("failed to get trades for market")
	ErrTradeServiceGetPositionsByParty = errors.New("failed to get positions for party")
	ErrTradeServiceGetByOrderID        = errors.New("failed to get trades for order ID")
	// MarketService...
	ErrMarketServiceGetMarkets    = errors.New("failed to get markets")
	ErrMarketServiceGetByID       = errors.New("failed to get market for ID")
	ErrMarketServiceGetDepth      = errors.New("failed to get market depth")
	ErrMarketServiceGetMarketData = errors.New("failed to get market data")
	// AccountService...
	ErrAccountServiceGetMarketAccounts = errors.New("failed to get market accounts")
	// AccountService...
	ErrAccountServiceGetFeeInfrastructureAccounts = errors.New("failed to get fee infrastructure accounts")
	ErrAccountServiceGetPartyAccounts             = errors.New("failed to get party accounts")
	// RiskService...
	ErrRiskServiceGetMarginLevelsByID = errors.New("failed to get margin levels")
	// CandleService...
	ErrCandleServiceGetCandles = errors.New("failed to get candles")
	// PartyService...
	ErrPartyServiceGetAll  = errors.New("failed to get parties")
	ErrPartyServiceGetByID = errors.New("failed to get party for ID")
	// TimeService...
	ErrTimeServiceGetTimeNow = errors.New("failed to get time now")
	// Blockchain...
	ErrBlockchainBacklogLength = errors.New("failed to get backlog length from blockchain")
	ErrBlockchainNetworkInfo   = errors.New("failed to get network info from blockchain")
	ErrBlockchainGenesisTime   = errors.New("failed to get genesis time from blockchain")
	ErrBlockchainChainID       = errors.New("failed to get chain ID from blockchain")
	// ErrMissingProposalID returned if proposal with this id is missing.
	ErrMissingProposalID = errors.New("missing proposal id")
	// ErrMissingProposalReference returned if proposal with this reference is not found.
	ErrMissingProposalReference = errors.New("failed to find proposal with the reference")
	// ErrMissingWithdrawalID is returned when the ID is missing from the request.
	ErrMissingWithdrawalID = errors.New("missing withdrawal ID")
	// ErrMissingOracleSpecID is returned when the ID is missing from the request.
	ErrMissingOracleSpecID = errors.New("missing oracle spec ID")
	// ErrMissingDepositID is returned when the ID is missing from the request.
	ErrMissingDepositID = errors.New("missing deposit ID")
)

API Errors and descriptions.

Functions

func ErrorMap

func ErrorMap() map[string]int32

ErrorMap returns a map of error to code, which is a mapping between API errors and Vega API specific numeric codes.

Types

type Blockchain

type Blockchain interface {
	SubmitTransactionSync(ctx context.Context, tx *commandspb.Transaction) (*tmctypes.ResultBroadcastTx, error)
	SubmitTransactionAsync(ctx context.Context, tx *commandspb.Transaction) (*tmctypes.ResultBroadcastTx, error)
	SubmitTransactionCommit(ctx context.Context, tx *commandspb.Transaction) (*tmctypes.ResultBroadcastTxCommit, error)
	SubmitRawTransactionSync(ctx context.Context, tx []byte) (*tmctypes.ResultBroadcastTx, error)
	SubmitRawTransactionAsync(ctx context.Context, tx []byte) (*tmctypes.ResultBroadcastTx, error)
	SubmitRawTransactionCommit(ctx context.Context, tx []byte) (*tmctypes.ResultBroadcastTxCommit, error)
	CheckTransaction(ctx context.Context, tx *commandspb.Transaction) (*tmctypes.ResultCheckTx, error)
	CheckRawTransaction(ctx context.Context, tx []byte) (*tmctypes.ResultCheckTx, error)
	GetGenesisTime(ctx context.Context) (genesisTime time.Time, err error)
	GetChainID(ctx context.Context) (chainID string, err error)
	GetNetworkInfo(ctx context.Context) (netInfo *tmctypes.ResultNetInfo, err error)
	GetStatus(ctx context.Context) (status *tmctypes.ResultStatus, err error)
	GetUnconfirmedTxCount(ctx context.Context) (count int, err error)
	Health() (*tmctypes.ResultHealth, error)
}

Blockchain ...

type Config

type Config struct {
	Level           encoding.LogLevel `long:"log-level"`
	Timeout         encoding.Duration `long:"timeout"`
	Port            int               `long:"port"`
	IP              string            `long:"ip"`
	StreamRetries   int               `long:"stream-retries"`
	DisableTxCommit bool              `long:"disable-tx-commit"`

	REST RESTServiceConfig `group:"REST" namespace:"rest"`
}

Config represents the configuration of the api package.

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 EventService

type EventService interface {
	ObserveEvents(ctx context.Context, retries int, eTypes []events.Type, batchSize int, filters ...subscribers.EventFilter) (<-chan []*eventspb.BusEvent, chan<- int)
}

type EvtForwarder

type EvtForwarder interface {
	Forward(ctx context.Context, e *commandspb.ChainEvent, pk string) error
}

EvtForwarder

type GRPC

type GRPC struct {
	Config
	// contains filtered or unexported fields
}

GRPCServer represent the grpc api provided by the vega node.

func NewGRPC

func NewGRPC(
	log *logging.Logger,
	config Config,
	stats *stats.Stats,
	client Blockchain,
	evtfwd EvtForwarder,
	timeService *vegatime.Svc,
	eventService *subscribers.Service,
	powParams ProofOfWorkParams,
) *GRPC

NewGRPC create a new instance of the GPRC api for the vega node.

func (*GRPC) RegisterService

func (g *GRPC) RegisterService(f func(*grpc.Server))

func (*GRPC) ReloadConf

func (g *GRPC) ReloadConf(cfg Config)

ReloadConf update the internal configuration of the GRPC server.

func (*GRPC) Start

func (g *GRPC) Start()

Start start the grpc server.

func (*GRPC) Stop

func (g *GRPC) Stop()

Stop stops the GRPC server.

func (*GRPC) UpdateProtocolServices

func (s *GRPC) UpdateProtocolServices(
	evtforwarder EvtForwarder,
	timesvc *vegatime.Svc,
	evtsvc EventService,
	powParams ProofOfWorkParams,
)

type ProofOfWorkParams

type ProofOfWorkParams interface {
	SpamPoWNumberOfPastBlocks() uint32
	SpamPoWDifficulty() uint32
	SpamPoWHashFunction() string
	SpamPoWNumberOfTxPerBlock() uint32
	SpamPoWIncreasingDifficulty() bool
	BlockData() (uint64, string)
	IsReady() bool
}

type RESTServiceConfig

type RESTServiceConfig struct {
	Port       int           `long:"port" description:"Listen for connection on port <port>"`
	IP         string        `long:"ip" description:"Bind to address <ip>"`
	Enabled    encoding.Bool `long:"enabled" choice:"true"  description:"Start the REST gateway"`
	APMEnabled encoding.Bool `long:"apm-enabled" choice:"true"  description:" "`
}

RESTGatewayServiceConfig represent the configuration of the rest service.

type TimeService

type TimeService interface {
	GetTimeNow() time.Time
}

TimeService ...

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package rest contains code for running the REST-to-gRPC gateway.
Package rest contains code for running the REST-to-gRPC gateway.

Jump to

Keyboard shortcuts

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