xprotocol

package
v0.0.0-...-872243e Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2019 License: GPL-3.0, LGPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidQuantity         = `{Code:77,Error:"orderbook: invalid order quantity."}`
	ErrInvalidPrice            = `{Code:78,Error:"orderbook: invalid order price."}`
	ErrOrderExists             = `{Code:79,Error:"orderbook: order already exists."}`
	ErrOrderNotExists          = `{Code:80,Error:"orderbook: order does not exist."}`
	ErrInsufficientQuantity    = `{Code:81,Error:"orderbook: insufficient quantity to calculate price."}`
	ErrOrderObjectNil          = `{Code:82,Error:"orderbook: order object is nil."}`
	ErrOrderQueueObjectNil     = `{Code:83,Error:"orderbook: order queue object is nil."}`
	ErrCompressDataNil         = `{Code:84,Error:"orderbook: compress data is nil."}`
	ErrCompressNewWriterFail   = `{Code:85,Error:"orderbook: get compress writer fail."}`
	ErrUnCompressDataNil       = `{Code:86,Error:"orderbook: uncompress data is nil."}`
	ErrUnCompressNewReaderFail = `{Code:87,Error:"orderbook: get uncompress reader fail."}`
	ErrMatchOrderBookFail      = `{Code:88,Error:"orderbook: match fail."}`
	ErrOrderBookObjectNil      = `{Code:89,Error:"orderbook: order book object is nil."}`
	ErrOrderInsufficient       = `{Code:90,Error:"Insufficient Order Balance."}`
	ErrGetODBError             = `{Code:91,Error:"get orderbook error."}`
	ErrMatchResNil             = `{Code:92,Error:"match result is nil."}`
	ErrNotODBTxData            = `{Code:93,Error:"not ODB tx data."}`
	ErrAlreadyUpdateMatchRes   = `{Code:94,Error:"match result has already been updated."}`
	ErrBlockNumMiss            = `{Code:95,Error:"block number miss."}`
	ErrNotInGroup              = `{Code:96,Error:"node not in group."}`
	ErrGetMatchResFail         = `{Code:97,Error:"get match result fail."}`
	ErrEncodeMatchResFail      = `{Code:98,Error:"encode match result fail."}`
	ErrCompressMatchResFail    = `{Code:99,Error:"compress mach result fail."}`
	ErrNewMatchResTxFail       = `{Code:100,Error:"new match result tx fail."}`
)

OrderBook erros

View Source
var (
	CancelOrders *list.List
	Match        bool
	MatchTrade   []string

	OB   = common.NewSafeMap(10)
	UNIT = common.NewSafeMap(10)

	MatchNonce = common.NewSafeMap(10)

	EXCHANGE_DEFAULT_FEE decimal.Decimal

	ReOrgList *common.Queue
)
View Source
var (
	MAXPRICE, _ = decimal.NewFromString("100000000000000")
)

Functions

func AddNewTrade

func AddNewTrade(trade string, local bool) error

func CalcPriceFromHistory

func CalcPriceFromHistory(p1 decimal.Decimal, p2 decimal.Decimal, prev decimal.Decimal, valids []*PriceLevel) decimal.Decimal

func CallOrderTest

func CallOrderTest(statedb *state.StateDB)

func CancelOrder

func CancelOrder(mr *MatchRes)

func Compress

func Compress(c []byte) (string, error)

//compress

func DeepCopy

func DeepCopy(d *orderbook.XvcOrderBook, trade string, nonce *big.Int) *orderbook.XvcOrderBook

func DeepCopyCurrentCancelOrders

func DeepCopyCurrentCancelOrders(l *list.List) []*list.Element

func DeepCopy_Tmp

func DeepCopy_Tmp(d *orderbook.XvcOrderBook, trade string, nonce *big.Int) *orderbook.XvcOrderBook

func DoReSendTx

func DoReSendTx()

func EncodeMatchRes

func EncodeMatchRes(res *MatchRes) (string, error)

func ExecMatchResTx

func ExecMatchResTx(data MatchResData) error

func FindOrder

func FindOrder(e *orderbook.XvcOrder) *orderbook.XvcOrder

func GetABByTrade

func GetABByTrade(trade string) (string, string)

trade = A/B

func GetCancelOrder

func GetCancelOrder() (int, []string)

func GetDefaultFee

func GetDefaultFee() decimal.Decimal

func GetOB

func GetOB(trade string) *orderbook.XvcOrderBook

func GetPairList

func GetPairList() (string, error)

func GetTradeFromMatchRes

func GetTradeFromMatchRes(res string) string

func GetUnit

func GetUnit(trade string) (decimal.Decimal, decimal.Decimal, error)

trade: A/B return: U_A,U_B 1A = U_A*e 1B = U_B*e 1A = UA*unit for example: 1BTC = 10^8 cong

func GetZipData

func GetZipData(mr *MatchRes) (string, error)

func InitMatchNonce

func InitMatchNonce()

func InitOb

func InitOb()

func InitTrade

func InitTrade()

func InitUnit

func InitUnit()

func Init_match_res

func Init_match_res()

func Init_quit

func Init_quit()

func Init_startmatch

func Init_startmatch()

func Init_timeout

func Init_timeout()

func InsertByNonce

func InsertByNonce(tx *types.Transaction)

func InsertCancelOrder

func InsertCancelOrder(id string)

func InsertToOrderBook

func InsertToOrderBook(msg string, ch chan interface{}) error

func InsertToOrderBook2

func InsertToOrderBook2(msg string)

func IsClosed

func IsClosed(ch <-chan interface{}) bool

func IsOrderBalanceOk

func IsOrderBalanceOk(from string, trade string, side string, price decimal.Decimal, quantity decimal.Decimal, fusion decimal.Decimal, B decimal.Decimal, A decimal.Decimal, ch chan interface{})

func MatchTimeOut

func MatchTimeOut(trade string)

func MatchXvcOrder

func MatchXvcOrder(trade string, nonce *big.Int) error

func MyClose

func MyClose(ch chan bool)

func OrderDealedInfo

func OrderDealedInfo(blockNr rpc.BlockNumber, trade string) (string, error)

func Orders

func Orders(trade string) (string, error)

func ReOrgOrder

func ReOrgOrder(txs types.Transactions)

func ReceivAllOrder

func ReceivAllOrder()

func RecvOrder

func RecvOrder(msg string, ch chan interface{})

func RecvOrder2

func RecvOrder2(msg string)

func RemoveOb

func RemoveOb(d *orderbook.XvcOrderBook)

func RemoveOb2

func RemoveOb2(d *orderbook.XvcOrderBook)

func RemoveOb_Tmp

func RemoveOb_Tmp(d *orderbook.XvcOrderBook)

func RevertMatchResRealData

func RevertMatchResRealData(mr *MatchRes)

func RevertMatchResRealData2

func RevertMatchResRealData2(mr *MatchRes)

func SendMatchResTx

func SendMatchResTx(trade string)

func SendOrderbookTx

func SendOrderbookTx(res_compress string, matchnonce *big.Int, trade string) error

func SettleOrders

func SettleOrders(evm *vm.EVM, from common.Address, data string)

func Start

func Start()

exchange start in gdcrm init

func StartXvcMatch

func StartXvcMatch(trade string)

func UnCompress

func UnCompress(s string) (string, error)

//uncompress

func UpdateOB

func UpdateOB(data string)

func UpdateOrder

func UpdateOrder(mr *MatchRes)

func WaitStop

func WaitStop()

Types

type CurrentVolume

type CurrentVolume struct {
	Id  string
	Vol string
}

type MatchRes

type MatchRes struct {
	Price   string
	Done    []*orderbook.XvcOrder
	Volumes string
	Orders  int

	CurVolume []*CurrentVolume

	//cancel
	Cancel []string
}

func DecodeMatchRes

func DecodeMatchRes(s string) (*MatchRes, error)

func GetMatchRes

func GetMatchRes(s string) (*MatchRes, error)

type MatchResData

type MatchResData struct {
	Nonce *big.Int
	Trade string
	Mr    *MatchRes
}

type PriceLevel

type PriceLevel struct {
	Price  string
	Volume string
	Side   string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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