executor

package
Version: v1.65.3 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2021 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, coinPrecision int64) int64

CalcActualCost 计算实际花费

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 买单深度是按价格倒序,由高到低

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 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)

QueryMarketDepth 这里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, coinPrecision int64) int64

SafeMul 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

NewAction ...

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)

LimitOrder ...

func (*Action) OpSwap

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

OpSwap 反转

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