admin

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: BlueOak-1.0.0 Imports: 31 Imported by: 2

Documentation

Overview

Package admin provides a password protected https server to send commands to a running dex server.

Index

Constants

View Source
const RFC3339Milli = "2006-01-02T15:04:05.999Z07:00"

RFC3339Milli is the RFC3339 time formatting with millisecond precision.

Variables

This section is empty.

Functions

func PasswordHashPrompt

func PasswordHashPrompt(ctx context.Context, prompt string) ([sha256.Size]byte, error)

PasswordHashPrompt prompts the user to enter a password and returns its SHA256 hash. Password must not be an empty string.

func PasswordPrompt

func PasswordPrompt(ctx context.Context, prompt string) ([]byte, error)

PasswordPrompt prompts the user to enter a password. Password must not be an empty string.

func UseLogger

func UseLogger(logger slog.Logger)

UseLogger sets the logger for the admin package.

Types

type APITime

type APITime struct {
	time.Time
}

APITime marshals and unmarshals a time value in time.RFC3339Nano format.

func (*APITime) MarshalJSON

func (at *APITime) MarshalJSON() ([]byte, error)

MarshalJSON marshals APITime to a JSON string in RFC3339 format except with millisecond precision.

func (*APITime) UnmarshalJSON

func (at *APITime) UnmarshalJSON(b []byte) error

UnmarshalJSON unmarshals JSON string containing a time in RFC3339 format with millisecond precision into an APITime.

type AssetInfo

type AssetInfo struct {
	dex.Asset
	CurrentFeeRate uint64   `json:"currentFeeRate,omitempty"`
	ScaledFeeRate  uint64   `json:"scaledFeeRate,omitempty"`
	Synced         bool     `json:"synced"`
	Errors         []string `json:"errors,omitempty"`
}

AssetInfo is the result of the asset GET. Note that ScaledFeeRate is CurrentFeeRate multiplied by an operator-specified fee scale rate for this asset, and then limited by the dex.Asset.MaxFeeRate.

type AssetPost

type AssetPost struct {
	FeeRateScale *float64 `json:"feeRateScale,omitempty"`
}

AssetPost is the expected structure of the asset POST data.

type ForgiveResult

type ForgiveResult struct {
	AccountID   string  `json:"accountid"`
	Forgiven    bool    `json:"forgiven"`
	Unbanned    bool    `json:"unbanned"`
	ForgiveTime APITime `json:"forgivetime"`
}

ForgiveResult holds the result of a forgive_match.

type MarketStatus

type MarketStatus struct {
	Name          string `json:"market,omitempty"`
	Running       bool   `json:"running"`
	EpochDuration uint64 `json:"epochlen"`
	ActiveEpoch   int64  `json:"activeepoch"`
	StartEpoch    int64  `json:"startepoch"`
	SuspendEpoch  int64  `json:"finalepoch,omitempty"`
	PersistBook   *bool  `json:"persistbook,omitempty"`
}

MarketStatus summarizes the operational status of a market.

type MatchData added in v0.2.0

type MatchData struct {
	ID          string `json:"id"`
	TakerSell   bool   `json:"takerSell"`
	Maker       string `json:"makerOrder"`
	MakerAcct   string `json:"makerAcct"`
	MakerSwap   string `json:"makerSwap"`
	MakerRedeem string `json:"makerRedeem"`
	MakerAddr   string `json:"makerAddr"`
	Taker       string `json:"takerOrder"`
	TakerAcct   string `json:"takerAcct"`
	TakerSwap   string `json:"takerSwap"`
	TakerRedeem string `json:"takerRedeem"`
	TakerAddr   string `json:"takerAddr"`
	EpochIdx    uint64 `json:"epochIdx"`
	EpochDur    uint64 `json:"epochDur"`
	Quantity    uint64 `json:"quantity"`
	Rate        uint64 `json:"rate"`
	BaseRate    uint64 `json:"baseFeeRate"`
	QuoteRate   uint64 `json:"quoteFeeRate"`
	Active      bool   `json:"active"`
	Status      string `json:"status"`
}

MatchData describes a match.

type ResumeResult

type ResumeResult struct {
	Market     string  `json:"market"`
	StartEpoch int64   `json:"startepoch"`
	StartTime  APITime `json:"starttime"`
}

ResumeResult is the result of a market resume request.

type Server

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

Server is a multi-client https server.

func NewServer

func NewServer(cfg *SrvConfig) (*Server, error)

NewServer is the constructor for a new Server.

func (*Server) Run

func (s *Server) Run(ctx context.Context)

Run starts the server.

type SrvConfig

type SrvConfig struct {
	Core            SvrCore
	Addr, Cert, Key string
	AuthSHA         [32]byte
	NoTLS           bool
}

SrvConfig holds variables needed to create a new Server.

type SuspendResult

type SuspendResult struct {
	Market      string  `json:"market"`
	FinalEpoch  int64   `json:"finalepoch"`
	SuspendTime APITime `json:"supendtime"`
}

SuspendResult describes the result of a market suspend request. FinalEpoch is the last epoch before shutdown, and it the market will run for it's entire duration. As such, SuspendTime is the time at which the market is closed, immediately after close of FinalEpoch.

type SvrCore

type SvrCore interface {
	AccountInfo(acctID account.AccountID) (*db.Account, error)
	UserMatchFails(aid account.AccountID, n int) ([]*auth.MatchFail, error)
	Notify(acctID account.AccountID, msg *msgjson.Message)
	NotifyAll(msg *msgjson.Message)
	ConfigMsg() json.RawMessage
	Asset(id uint32) (*asset.BackedAsset, error)
	SetFeeRateScale(assetID uint32, scale float64)
	ScaleFeeRate(assetID uint32, rate uint64) uint64
	MarketRunning(mktName string) (found, running bool)
	MarketStatus(mktName string) *market.Status
	MarketStatuses() map[string]*market.Status
	SuspendMarket(name string, tSusp time.Time, persistBooks bool) (*market.SuspendEpoch, error)
	ResumeMarket(name string, asSoonAs time.Time) (startEpoch int64, startTime time.Time, err error)
	ForgiveMatchFail(aid account.AccountID, mid order.MatchID) (forgiven, unbanned bool, err error)
	AccountMatchOutcomesN(user account.AccountID, n int) ([]*auth.MatchOutcome, error)
	BookOrders(base, quote uint32) (orders []*order.LimitOrder, err error)
	EpochOrders(base, quote uint32) (orders []order.Order, err error)
	MarketMatchesStreaming(base, quote uint32, includeInactive bool, N int64, f func(*dexsrv.MatchData) error) (int, error)
	EnableDataAPI(yes bool)
	CreatePrepaidBonds(n int, strength uint32, durSecs int64) ([][]byte, error)
}

SvrCore is satisfied by server/dex.DEX.

Jump to

Keyboard shortcuts

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