executor

package
v1.67.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//KeyPrefixStateDB state db key必须前缀
	KeyPrefixStateDB = "mavl-exchange-"
	//KeyPrefixLocalDB local db的key必须前缀
	KeyPrefixLocalDB = "LODB-exchange"
)

Variables

This section is empty.

Functions

func CalcActualCost

func CalcActualCost(op int32, amount int64, price, coinPrecision int64) int64

CalcActualCost Calculate actual cost

func CheckAmount

func CheckAmount(amount, coinPrecision int64) bool

CheckAmount 最小交易 1coin

func CheckCount

func CheckCount(count int32) bool

CheckCount ...

func CheckDirection

func CheckDirection(direction int32) bool

CheckDirection ...

func CheckExchangeAsset

func CheckExchangeAsset(coinExec string, left, right *et.Asset) bool

CheckExchangeAsset

func CheckOp

func CheckOp(op int32) bool

CheckOp ...

func CheckPrice

func CheckPrice(price int64) bool

CheckPrice price 1<=price<=1e16

func CheckStatus

func CheckStatus(status int32) bool

CheckStatus ...

func Direction

func Direction(op int32) int32

Direction Buying depth is in reverse order by price, from high to low

func GetName

func GetName() string

GetName get driver name

func Init

func Init(name string, cfg *types.Chain33Config, sub []byte)

Init register dapp

func InitExecType

func InitExecType()

InitExecType Init Exec Type

func NewExchange

func NewExchange() drivers.Driver

NewExchange ...

func NewHistoryOrderTable

func NewHistoryOrderTable(kvdb db.KV) *table.Table

NewHistoryOrderTable ...

func NewMarketDepthTable

func NewMarketDepthTable(kvdb db.KV) *table.Table

NewMarketDepthTable 新建表

func NewMarketOrderTable

func NewMarketOrderTable(kvdb db.KV) *table.Table

NewMarketOrderTable ...

func OpSwap

func OpSwap(op int32) int32

OpSwap ...

func ParseCoins added in v1.66.0

func ParseCoins(cfg *types.Chain33Config, tradeKey string, height int64) (coins []et.CoinCfg, err error)

func ParseConfig added in v1.66.0

func ParseConfig(cfg *types.Chain33Config, height int64) (*et.Econfig, error)

func ParseStrings added in v1.66.0

func ParseStrings(cfg *types.Chain33Config, tradeKey string, height int64) (ret []string, err error)

func ParseSymbols added in v1.67.0

func ParseSymbols(cfg *types.Chain33Config, tradeKey string, height int64) (symbols map[string]*et.Trade, err error)

func QueryHistoryOrderList

func QueryHistoryOrderList(localdb dbm.KV, left, right *et.Asset, primaryKey string, count, direction int32) (types.Message, error)

QueryHistoryOrderList Only the order information is returned

func QueryMarketDepth

func QueryMarketDepth(localdb dbm.KV, left, right *et.Asset, op int32, primaryKey string, count int32) (*et.MarketDepthList, error)

QueryMarketDepth 这里primaryKey当作主键索引来用, The first query does not need to fill in the value, pay according to the price from high to low, selling orders according to the price from low to high query

func QueryOrderList

func QueryOrderList(localdb dbm.KV, addr string, status, count, direction int32, primaryKey string) (types.Message, error)

QueryOrderList Displays the latest by default

func SafeMul

func SafeMul(x, y, coinPrecision int64) int64

SafeMul Safe multiplication of large numbers, prevent overflow

Types

type Action

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

Action action struct

func NewAction

func NewAction(e *exchange, tx *types.Transaction, index int) *Action

NewAction ...

func (*Action) EntrustOrder added in v1.66.3

func (a *Action) EntrustOrder(payload *et.EntrustOrder) (*types.Receipt, error)

func (*Action) EntrustRevokeOrder added in v1.66.3

func (a *Action) EntrustRevokeOrder(payload *et.EntrustRevokeOrder) (*types.Receipt, error)

func (*Action) ExchangeBind added in v1.66.3

func (a *Action) ExchangeBind(payload *et.ExchangeBind) (*types.Receipt, error)

func (*Action) GetIndex

func (a *Action) GetIndex() int64

GetIndex get index

func (*Action) GetKVSet

func (a *Action) GetKVSet(order *et.Order) (kvset []*types.KeyValue)

GetKVSet get kv set

func (*Action) LimitOrder

func (a *Action) LimitOrder(payload *et.LimitOrder, entrustAddr string) (*types.Receipt, error)

LimitOrder ...

func (*Action) OpSwap

func (a *Action) OpSwap(op int32) int32

OpSwap reverse

func (*Action) RevokeOrder

func (a *Action) RevokeOrder(payload *et.RevokeOrder) (*types.Receipt, error)

RevokeOrder ...

type HistoryOrderRow

type HistoryOrderRow struct {
	*ety.Order
}

HistoryOrderRow table meta 结构

func NewHistoryOrderRow

func NewHistoryOrderRow() *HistoryOrderRow

NewHistoryOrderRow ...

func (*HistoryOrderRow) CreateRow

func (m *HistoryOrderRow) CreateRow() *table.Row

CreateRow ...

func (*HistoryOrderRow) Get

func (m *HistoryOrderRow) Get(key string) ([]byte, error)

Get 按照indexName 查询 indexValue

func (*HistoryOrderRow) SetPayload

func (m *HistoryOrderRow) SetPayload(data types.Message) error

SetPayload 设置数据

type MarketDepthRow

type MarketDepthRow struct {
	*ety.MarketDepth
}

MarketDepthRow table meta 结构

func NewMarketDepthRow

func NewMarketDepthRow() *MarketDepthRow

NewMarketDepthRow 新建一个meta 结构

func (*MarketDepthRow) CreateRow

func (m *MarketDepthRow) CreateRow() *table.Row

CreateRow 新建数据行(注意index 数据一定也要保存到数据中,不能就保存eventid)

func (*MarketDepthRow) Get

func (m *MarketDepthRow) Get(key string) ([]byte, error)

Get 按照indexName 查询 indexValue

func (*MarketDepthRow) SetPayload

func (m *MarketDepthRow) SetPayload(data types.Message) error

SetPayload 设置数据

type OrderRow

type OrderRow struct {
	*ety.Order
}

OrderRow table meta 结构

func NewOrderRow

func NewOrderRow() *OrderRow

NewOrderRow 新建一个meta 结构

func (*OrderRow) CreateRow

func (r *OrderRow) CreateRow() *table.Row

CreateRow ...

func (*OrderRow) Get

func (r *OrderRow) Get(key string) ([]byte, error)

Get 按照indexName 查询 indexValue

func (*OrderRow) SetPayload

func (r *OrderRow) SetPayload(data types.Message) error

SetPayload 设置数据

Jump to

Keyboard shortcuts

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