executor

package
v1.64.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: BSD-3-Clause Imports: 10 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 int64) int64

计算实际花费

func CheckAmount

func CheckAmount(amount int64) bool

最小交易1e8

func CheckCount

func CheckCount(count int32) bool

func CheckDirection

func CheckDirection(direction int32) bool

func CheckExchangeAsset

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

检查交易得资产是否合法

func CheckOp

func CheckOp(op int32) bool

func CheckPrice

func CheckPrice(price int64) bool

price 精度允许范围 1<=price<=1e16 整数

func CheckStatus

func CheckStatus(status int32) bool

func Direction

func Direction(op int32) int32

买单深度是按价格倒序,由高到低

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

func NewHistoryOrderTable

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

func NewMarketDepthTable

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

NewTable 新建表

func NewMarketOrderTable

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

func OpSwap

func OpSwap(op int32) int32

func QueryHistoryOrderList

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

QueryHistoryOrderList 只返回成交的订单信息

func QueryMarketDepth

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

这里primaryKey当作主键索引来用,首次查询不需要填值,买单按价格由高往低,卖单按价格由低往高查询

func QueryOrderList

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

QueryOrderList,默认展示最新的

func SafeMul

func SafeMul(x, y int64) int64

math库中的安全大数乘法,防溢出

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

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) (*types.Receipt, error)

func (*Action) OpSwap

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

反转

func (*Action) RevokeOrder

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

type HistoryOrderRow

type HistoryOrderRow struct {
	*ety.Order
}

HistoryOrderRow table meta 结构

func NewHistoryOrderRow

func NewHistoryOrderRow() *HistoryOrderRow

func (*HistoryOrderRow) CreateRow

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

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

NewOracleRow 新建一个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