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.

                    type AssetPost

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

                      AssetPost is the expected structure of the asset POST data.

                      type BanResult

                      type BanResult struct {
                      	AccountID  string  `json:"accountid"`
                      	BrokenRule byte    `json:"brokenrule"`
                      	BanTime    APITime `json:"bantime"`
                      }

                        BanResult holds the result of a ban.

                        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 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
                                    }

                                      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 {
                                        	Accounts() (accts []*db.Account, err error)
                                        	AccountInfo(acctID account.AccountID) (*db.Account, 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)
                                        	Penalize(aid account.AccountID, rule account.Rule, details string) error
                                        	Unban(aid account.AccountID) error
                                        	ForgiveMatchFail(aid account.AccountID, mid order.MatchID) (forgiven, unbanned bool, err error)
                                        }

                                          SvrCore is satisfied by server/dex.DEX.

                                          type UnbanResult

                                          type UnbanResult struct {
                                          	AccountID string  `json:"accountid"`
                                          	UnbanTime APITime `json:"unbantime"`
                                          }

                                            UnbanResult holds the result of an unban.