executor

package
v1.66.3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: BSD-3-Clause Imports: 14 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 ParseCoins added in v1.66.0

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

func ParseConfig added in v1.66.0

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

func ParseStrings added in v1.66.0

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

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(statedb dbm.KV, 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) 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 反转

func (*Action) RevokeOrder

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

RevokeOrder ...

func (*Action) RevokeOrder_Fix2 added in v1.66.3

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

func (*Action) RevokeOrder_Fix3 added in v1.66.3

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

func (*Action) RevokeOrder_Fix4 added in v1.66.3

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

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