db

package
v0.0.0-...-c5b2729 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2018 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusOpen     = int64(0)
	StatusFilled   = int64(1)
	StatusUnfunded = int64(2)
)

Variables

This section is empty.

Functions

func GetDB

func GetDB(connectionString, passwordURI string) (*gorm.DB, error)

Types

type FillRecord

type FillRecord struct {
	OrderHash                 string `json:"orderHash"`
	FilledTakerTokenAmount    string `json:"filledTakerTokenAmount"`
	CancelledTakerTokenAmount string `json:"cancelledTakerTokenAmount"`
}

type IndexConsumer

type IndexConsumer struct {
	// contains filtered or unexported fields
}

func NewIndexConsumer

func NewIndexConsumer(db *gorm.DB, status int64, concurrency int) *IndexConsumer

func (*IndexConsumer) Consume

func (consumer *IndexConsumer) Consume(msg channels.Delivery)

type Indexer

type Indexer struct {
	// contains filtered or unexported fields
}

func NewIndexer

func NewIndexer(db *gorm.DB, status int64) *Indexer

func (*Indexer) Index

func (indexer *Indexer) Index(order *types.Order) error

Index takes an order and saves it to the database

func (*Indexer) RecordFill

func (indexer *Indexer) RecordFill(fillRecord *FillRecord) error

RecordFill takes information about a filled order and updates the corresponding database record, if any exists.

func (*Indexer) RecordSpend

func (indexer *Indexer) RecordSpend(makerAddress, tokenAddress, zrxAddress *types.Address, balance *types.Uint256) error

RecordSpend takes information about a token transfer, and updates any orders that might have become unfillable as a result of the transfer.

type Order

type Order struct {
	types.Order
	CreatedAt           time.Time
	UpdatedAt           time.Time
	OrderHash           []byte  `gorm:"primary_key"`
	Status              int64   `gorm:"index"`
	Price               float64 `gorm:"index:price"`
	FeeRate             float64 `gorm:"index:price"`
	MakerTokenRemaining *types.Uint256
	MakerFeeRemaining   *types.Uint256
}

func (*Order) Save

func (order *Order) Save(db *gorm.DB, status int64) *gorm.DB

Save records the order in the database, defaulting to the specified status. Status should either be db.StatusOpen, or db.StatusUnfunded. If the order is filled based on order.TakerTokenAmountFilled + order.TakerTokenAmountCancelled the status will be recorded as db.StatusFilled regardless of the specified status.

type Pair

type Pair struct {
	TokenA *types.Address
	TokenB *types.Address
}

Pair tracks pairs of tokens TokenA and TokenB

func GetAllTokenPairs

func GetAllTokenPairs(db *gorm.DB, offset, count int) ([]Pair, error)

GetAllTokenPairs returns an unfilitered list of Pairs based on the trading pairs currently present in the database, limited by a count and offset.

func GetTokenABPairs

func GetTokenABPairs(db *gorm.DB, tokenA, tokenB *types.Address) ([]Pair, error)

GetTokenABPairs returns a list of Pairs based on the trading pairs currrently present in the database, filtered to include only pairs that include both tokenA and tokenB. There should only be one distinct combination of both token pairs, so there is no offset or limit, but it still returns a list to provide the same return value as the other retrieval methods.

func GetTokenAPairs

func GetTokenAPairs(db *gorm.DB, tokenA *types.Address, offset, count int) ([]Pair, error)

GetTokenAPairs returns a list of Pairs based on the trading pairs currrently present in the database, filtered to include only pairs that include tokenA and limited by a count and offset.

func (*Pair) MarshalJSON

func (pair *Pair) MarshalJSON() ([]byte, error)

type RecordFillConsumer

type RecordFillConsumer struct {
	// contains filtered or unexported fields
}

func NewRecordFillConsumer

func NewRecordFillConsumer(db *gorm.DB, concurrency int) *RecordFillConsumer

func (*RecordFillConsumer) Consume

func (consumer *RecordFillConsumer) Consume(msg channels.Delivery)

type RecordSpendConsumer

type RecordSpendConsumer struct {
	// contains filtered or unexported fields
}

func NewRecordSpendConsumer

func NewRecordSpendConsumer(db *gorm.DB, concurrency int) *RecordSpendConsumer

func (*RecordSpendConsumer) Consume

func (consumer *RecordSpendConsumer) Consume(msg channels.Delivery)

type SpendRecord

type SpendRecord struct {
	TokenAddress   string `json:"tokenAddress"`
	SpenderAddress string `json:"spenderAddress"`
	ZrxToken       string `json:"zrxToken"`
	Balance        string `json:"balance"`
}

Jump to

Keyboard shortcuts

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