common

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: AGPL-3.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsCancelOrderTx added in v1.0.5

func IsCancelOrderTx(tx *types.Tx) bool

IsCancelOrderTx check if this transaction has cancel mov order input

func IsMatchedTx added in v1.0.5

func IsMatchedTx(tx *types.Tx) bool

IsMatchedTx check if this transaction has trade mov order input

Types

type MovDatabaseState

type MovDatabaseState struct {
	Height uint64
	Hash   *bc.Hash
}

MovDatabaseState is object to record DB image status

type MovUtxo

type MovUtxo struct {
	SourceID       *bc.Hash
	SourcePos      uint64
	Amount         uint64
	ControlProgram []byte
}

MovUtxo store the utxo information for mov order

type Order

type Order struct {
	FromAssetID      *bc.AssetID
	ToAssetID        *bc.AssetID
	Utxo             *MovUtxo
	RatioNumerator   int64
	RatioDenominator int64
	SellerProgram    []byte
	BlockHeight      uint64
	TxIndex          uint64
}

Order store all the order information

func NewOrderFromInput added in v1.0.5

func NewOrderFromInput(tx *types.Tx, inputIndex int) (*Order, error)

NewOrderFromInput convert txoutput to order

func NewOrderFromOutput added in v1.0.5

func NewOrderFromOutput(tx *types.Tx, outputIndex int, blockHeight, txIndex uint64) (*Order, error)

NewOrderFromOutput convert txinput to order

func (*Order) Cmp added in v1.1.0

func (o *Order) Cmp(other *Order) int

Cmp first compare the rate, if rate is equals, then compare the utxo hash

func (*Order) Key added in v1.0.5

func (o *Order) Key() string

Key return the unique key for representing this order

func (*Order) Rate

func (o *Order) Rate() float64

Rate return the exchange represented by float64

func (*Order) TradePair added in v1.0.5

func (o *Order) TradePair() *TradePair

TradePair return the trade pair info

func (*Order) UTXOHash added in v1.0.5

func (o *Order) UTXOHash() *bc.Hash

UTXOHash calculate the utxo hash of this order

type OrderSlice added in v1.0.5

type OrderSlice []*Order

OrderSlice is define for order's sort

func (OrderSlice) Len added in v1.0.5

func (o OrderSlice) Len() int

func (OrderSlice) Less added in v1.0.5

func (o OrderSlice) Less(i, j int) bool

func (OrderSlice) Swap added in v1.0.5

func (o OrderSlice) Swap(i, j int)

type TradePair

type TradePair struct {
	FromAssetID *bc.AssetID
	ToAssetID   *bc.AssetID
	Count       int
}

TradePair is the object for record trade pair info

func (*TradePair) Key added in v1.0.5

func (t *TradePair) Key() string

Key return the unique key for representing this trade pair

func (*TradePair) Reverse added in v1.0.5

func (t *TradePair) Reverse() *TradePair

Reverse return the reverse trade pair object

Jump to

Keyboard shortcuts

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