core

package
v0.0.22 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAssetNotExist = errors.New("asset not exist")
)
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 AssetService

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

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) Scan added in v0.0.4

func (s *CosiSignature) Scan(value interface{}) error

Scan implements the sql.Scanner interface for database deserialization.

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

func (*CosiSignature) Value added in v0.0.4

func (s *CosiSignature) Value() (driver.Value, error)

Value implements the driver.Valuer interface for database serialization.

type Exchange added in v0.0.6

type Exchange interface {
	Name() string
	GetPrice(ctx context.Context, asset *Asset) (decimal.Decimal, error)
}

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) MarshalBinary added in v0.0.5

func (p *PriceData) MarshalBinary() (data []byte, err error)

func (PriceData) Payload

func (p PriceData) Payload() []byte

func (*PriceData) UnmarshalBinary added in v0.0.5

func (p *PriceData) UnmarshalBinary(data []byte) error

type PriceRequest added in v0.0.6

type PriceRequest struct {
	Asset

	TraceID   string    `json:"trace_id,omitempty"`
	Receiver  *Receiver `json:"receiver,omitempty"`
	Signers   []*Signer `json:"signers,omitempty"`
	Threshold uint8     `json:"threshold"`
}

type Proposal added in v0.0.6

type Proposal struct {
	PriceRequest
	ProposalRequest `json:"-"`

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

func (Proposal) Export added in v0.0.6

func (p Proposal) Export() *PriceData

type ProposalRequest added in v0.0.6

type ProposalRequest struct {
	Asset

	TraceID   string          `json:"trace_id,omitempty"`
	Timestamp int64           `json:"timestamp,omitempty"`
	Price     decimal.Decimal `json:"price,omitempty"`
	Signers   []*Signer       `json:"signers,omitempty"`
	Signature *ProposalResp   `json:"signature,omitempty"`
}

func (ProposalRequest) Payload added in v0.0.6

func (p ProposalRequest) Payload() []byte

func (ProposalRequest) Verify added in v0.0.6

func (p ProposalRequest) Verify(resp *ProposalResp) bool

type ProposalResp added in v0.0.6

type ProposalResp struct {
	TraceID   string          `json:"trace_id,omitempty"`
	Index     uint64          `json:"index"`
	Signature *blst.Signature `json:"signature,omitempty"`
}

type Receiver added in v0.0.6

type Receiver struct {
	Members   []string `json:"members,omitempty"`
	Threshold uint8    `json:"threshold"`
}

type Signer added in v0.0.6

type Signer struct {
	Index     uint64          `json:"index,omitempty"`
	VerifyKey *blst.PublicKey `json:"verify_key,omitempty"`
}

type Subscriber added in v0.0.5

type Subscriber struct {
	ID         uint       `sql:"PRIMARY_KEY" json:"id"`
	CreatedAt  time.Time  `json:"created_at"`
	UpdatedAt  time.Time  `json:"updated_at"`
	DeletedAt  *time.Time `sql:"index" json:"deleted_at"`
	Name       string     `sql:"SIZE:255;" json:"name,omitempty"`
	RequestURL string     `sql:"SIZE:255;" json:"request_url,omitempty"`
}

type SubscriberStore added in v0.0.5

type SubscriberStore interface {
	Save(ctx context.Context, f *Subscriber) error
	All(ctx context.Context) ([]*Subscriber, error)
}

type System

type System struct {
	ConversationID string
	GasAsset       string
	GasAmount      decimal.Decimal
	SignKey        *blst.PrivateKey
	VerifyKey      *blst.PublicKey
}

System stores system information.

func (*System) SignProposal

func (s *System) SignProposal(p *ProposalRequest, index uint64) *ProposalResp

func (*System) VerifyData

func (s *System) VerifyData(req *PriceRequest, p *PriceData) bool

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
}

Jump to

Keyboard shortcuts

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