core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAssetNotExist = errors.New("asset not exist")
)

Functions

This section is empty.

Types

type Asset

type Asset struct {
	ID            string          `sql:"size:36;PRIMARY_KEY" json:"id,omitempty"`
	UpdatedAt     time.Time       `json:"updated_at,omitempty"`
	Name          string          `sql:"size:64" json:"name,omitempty"`
	Symbol        string          `sql:"size:32" json:"symbol,omitempty"`
	DisplaySymbol string          `sql:"size:32" json:"display_symbol,omitempty"`
	ChainID       string          `sql:"size:36" json:"chain_id,omitempty"`
	Price         decimal.Decimal `sql:"type:decimal(24,8)" json:"price_usd,omitempty"`
}

type AssetService

type AssetService interface {
	Find(ctx context.Context, id string) (*Asset, error)
	ListAll(ctx context.Context) ([]*Asset, error)
}

AssetService provides access to assets information in the remote system like mixin network.

type AssetStore

type AssetStore interface {
	Save(ctx context.Context, asset *Asset, columns ...string) error
	Find(ctx context.Context, id string) (*Asset, error)
	ListAll(ctx context.Context) ([]*Asset, error)
	ListPrices(ctx context.Context, ids ...string) (number.Values, error)
}

AssetStore defines operations for working with assets on db.

type FeedConfig

type FeedConfig struct {
	Asset
	Sources []string `json:"sources,omitempty"`
}

type Feeder

type Feeder struct {
	gorm.Model
	AssetID   string         `json:"asset_id,omitempty"`
	Threshold uint8          `json:"threshold,omitempty"`
	Opponents pq.StringArray `sql:"type:TEXT" json:"opponents,omitempty"`
}

type FeederStore

type FeederStore interface {
	SaveFeeder(ctx context.Context, f *Feeder) error
	AllFeeders(ctx context.Context) ([]*Feeder, error)
}

type MarketStore

type MarketStore interface {
	// ticker
	SaveTicker(ctx context.Context, ticker *Ticker) error
	FindTickers(ctx context.Context, assetID string) ([]*Ticker, error)
	AggregateTickers(ctx context.Context, assetID string) (*Ticker, error)
}

type Member

type Member struct {
	ID        int64           `json:"id"`
	ClientID  string          `json:"client_id"`
	Name      string          `json:"name"`
	VerifyKey *blst.PublicKey `json:"verify_key"`
}

func (*Member) Mask

func (m *Member) Mask() int64

func (*Member) VerifyProposal

func (m *Member) VerifyProposal(p *PriceData) bool

type PriceData

type PriceData struct {
	Timestamp int64           `json:"timestamp,omitempty"`
	AssetID   string          `json:"asset_id,omitempty"`
	Price     decimal.Decimal `json:"price,omitempty"`
	Mask      int64           `json:"mask,omitempty"`
	Signature *blst.Signature `json:"signature,omitempty"`
}

func (PriceData) Payload

func (p PriceData) Payload() []byte

type PriceProposal

type PriceProposal struct {
	PriceData

	Signatures map[int64]*blst.Signature `json:"signatures,omitempty"`
}

type RawTransaction

type RawTransaction struct {
	ID        int64     `sql:"PRIMARY_KEY" json:"id,omitempty"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	TraceID   string    `sql:"type:char(36);" json:"trace_id,omitempty"`
	Data      string    `sql:"type:TEXT" json:"data,omitempty"`
}

type System

type System struct {
	Admins         []string
	ConversationID string
	ClientID       string
	Members        []*Member
	Threshold      uint8
	SignKey        *blst.PrivateKey
	Version        string
}

System stores system information.

func (*System) Me

func (s *System) Me() *Member

func (*System) Member

func (s *System) Member(id int64) *Member

func (*System) MemberIDs

func (s *System) MemberIDs() []string

func (*System) MergeProposals

func (s *System) MergeProposals(p0, p1 *PriceProposal) *PriceProposal

func (*System) SignProposal

func (s *System) SignProposal(p *PriceProposal) *PriceProposal

func (*System) VerifyData

func (s *System) VerifyData(p *PriceData) bool

func (*System) VerifyProposal

func (s *System) VerifyProposal(p *PriceProposal) bool

type Ticker

type Ticker struct {
	AssetID   string          `json:"asset_id"`
	Source    string          `json:"source,omitempty"`
	Timestamp int64           `json:"timestamp,omitempty"`
	Price     decimal.Decimal `json:"price,omitempty"`
	VolumeUSD decimal.Decimal `json:"volume_usd,omitempty"`
}

type Transfer

type Transfer struct {
	ID        int64           `sql:"PRIMARY_KEY" json:"id,omitempty"`
	CreatedAt time.Time       `json:"created_at,omitempty"`
	UpdatedAt time.Time       `json:"updated_at,omitempty"`
	TraceID   string          `sql:"type:char(36)" json:"trace_id,omitempty"`
	AssetID   string          `sql:"type:char(36)" json:"asset_id,omitempty"`
	Amount    decimal.Decimal `sql:"type:decimal(64,8)" json:"amount,omitempty"`
	Memo      string          `sql:"size:200" json:"memo,omitempty"`
	Handled   types.BitBool   `sql:"type:bit(1)" json:"handled,omitempty"`
	Passed    types.BitBool   `sql:"type:bit(1)" json:"passed,omitempty"`
	Threshold uint8           `json:"threshold,omitempty"`
	Opponents pq.StringArray  `sql:"type:varchar(1024)" json:"opponents,omitempty"`
}

type WalletStore

type WalletStore interface {
	// Transfers
	CreateTransfers(ctx context.Context, transfers []*Transfer) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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