core

package
v0.0.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTrace = errors.New("invalid trace")
)

Functions

This section is empty.

Types

type Asset

type Asset struct {
	AssetID string `json:"asset_id,omitempty"`
	Symbol  string `json:"symbol,omitempty"`
}

type CosiSignature added in v0.0.2

type CosiSignature struct {
	blst.Signature
	Mask uint64
}

func (*CosiSignature) Bytes added in v0.0.2

func (s *CosiSignature) Bytes() []byte

func (*CosiSignature) FromBytes added in v0.0.2

func (s *CosiSignature) FromBytes(bts []byte) error

func (*CosiSignature) MarshalBinary added in v0.0.2

func (s *CosiSignature) MarshalBinary() (data []byte, err error)

func (*CosiSignature) MarshalJSON added in v0.0.2

func (s *CosiSignature) MarshalJSON() ([]byte, error)

func (*CosiSignature) String added in v0.0.2

func (s *CosiSignature) String() string

func (*CosiSignature) UnmarshalBinary added in v0.0.2

func (s *CosiSignature) UnmarshalBinary(data []byte) error

func (*CosiSignature) UnmarshalJSON added in v0.0.2

func (s *CosiSignature) UnmarshalJSON(b []byte) error

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)
	FindFeeders(ctx context.Context, assetID string) ([]*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() uint64

type PriceData

type PriceData struct {
	Timestamp int64           `json:"t,omitempty"`
	AssetID   string          `json:"a,omitempty"`
	Price     decimal.Decimal `json:"p,omitempty"`
	Signature *CosiSignature  `json:"s,omitempty"`
}

func (PriceData) Payload

func (p PriceData) Payload() []byte

type PriceProposal

type PriceProposal struct {
	PriceData

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

type Snapshot added in v0.0.2

type Snapshot struct {
	SnapshotID      string          `json:"snapshot_id"`
	CreatedAt       time.Time       `json:"created_at,omitempty"`
	TraceID         string          `json:"trace_id,omitempty"`
	AssetID         string          `json:"asset_id,omitempty"`
	OpponentID      string          `json:"opponent_id,omitempty"`
	Source          string          `json:"source,omitempty"`
	Amount          decimal.Decimal `json:"amount,omitempty"`
	Memo            string          `json:"memo,omitempty"`
	TransactionHash string          `json:"transaction_hash,omitempty"`
}

type System

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

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

func (*Ticker) ExportProposal added in v0.0.2

func (t *Ticker) ExportProposal() *PriceProposal

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"`
	Threshold uint8           `json:"threshold,omitempty"`
	Opponents pq.StringArray  `sql:"type:varchar(1024)" json:"opponents,omitempty"`
}

type WalletService added in v0.0.2

type WalletService interface {
	Transfer(ctx context.Context, transfer *Transfer) error
}

type WalletStore

type WalletStore interface {
	ListTransfers(ctx context.Context, limit int) ([]*Transfer, error)
	CreateTransfers(ctx context.Context, transfers []*Transfer) error
	ExpireTransfers(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