core

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: GPL-3.0 Imports: 14 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 En256CosiSignature added in v1.1.2

type En256CosiSignature struct {
	en256.Signature
	Mask uint64
}

func (*En256CosiSignature) Bytes added in v1.1.2

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

func (*En256CosiSignature) FromBytes added in v1.1.2

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

func (*En256CosiSignature) MarshalBinary added in v1.1.2

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

func (*En256CosiSignature) MarshalJSON added in v1.1.2

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

func (*En256CosiSignature) Scan added in v1.1.2

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

Scan implements the sql.Scanner interface for database deserialization.

func (*En256CosiSignature) String added in v1.1.2

func (s *En256CosiSignature) String() string

func (*En256CosiSignature) UnmarshalBinary added in v1.1.2

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

func (*En256CosiSignature) UnmarshalJSON added in v1.1.2

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

func (*En256CosiSignature) Value added in v1.1.2

func (s *En256CosiSignature) 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"`
	En256Signature *En256CosiSignature `json:"es,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) PayloadV1 added in v1.1.7

func (p PriceData) PayloadV1() ([]byte, error)

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"`
	En256Signatures map[uint64]*en256.Signature `json:"en256_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) PayloadV1 added in v1.1.7

func (p ProposalRequest) PayloadV1() ([]byte, error)

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"`
	En256Signature *en256.Signature `json:"en256_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"`
	En256VerifyKey *en256.PublicKey `json:"en256_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

	En256SignKey   *en256.PrivateKey
	En256VerifyKey *en256.PublicKey
}

System stores system information.

func (*System) SignProposal

func (s *System) SignProposal(p *ProposalRequest, signer *Signer) (*ProposalResp, error)

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