Documentation ¶
Index ¶
- Constants
- Variables
- func DoSettleBalance(coinbase common.Address, takerOrder, makerOrder *tradingstate.OrderItem, ...) error
- func GetTokenAbi() (*abi.ABI, error)
- func GetTradeQuantity(takerSide string, takerFeeRate *big.Int, takerBalance *big.Int, ...) (*big.Int, bool)
- func NewLDBEngine(cfg *Config) *taoxDAO.BatchDatabase
- func NewMongoDBEngine(cfg *Config) *taoxDAO.MongoDatabase
- func RunContract(chain consensus.ChainContext, statedb *state.StateDB, ...) (interface{}, error)
- type Config
- type PublicTaoXAPI
- type TaoX
- func (taox *TaoX) APIs() []rpc.API
- func (taox *TaoX) ApplyOrder(coinbase common.Address, chain consensus.ChainContext, statedb *state.StateDB, ...) ([]map[string]string, []*tradingstate.OrderItem, error)
- func (taox *TaoX) CommitOrder(coinbase common.Address, chain consensus.ChainContext, statedb *state.StateDB, ...) ([]map[string]string, []*tradingstate.OrderItem, error)
- func (taox *TaoX) GetLevelDB() taoxDAO.TaoXDAO
- func (taox *TaoX) GetMongoDB() taoxDAO.TaoXDAO
- func (taox *TaoX) GetStateCache() tradingstate.Database
- func (taox *TaoX) GetTokenDecimal(chain consensus.ChainContext, statedb *state.StateDB, tokenAddr common.Address) (*big.Int, error)
- func (taox *TaoX) GetTradingState(block *types.Block, author common.Address) (*tradingstate.TradingStateDB, error)
- func (taox *TaoX) GetTradingStateRoot(block *types.Block, author common.Address) (common.Hash, error)
- func (taox *TaoX) GetTriegc() *prque.Prque
- func (taox *TaoX) HasTradingState(block *types.Block, author common.Address) bool
- func (taox *TaoX) IsSDKNode() bool
- func (taox *TaoX) LogEpochPrice(epochNumber uint64, epochPriceResult map[common.Hash]*big.Int) error
- func (taox *TaoX) Overflow() bool
- func (taox *TaoX) ProcessCancelOrder(tradingStateDB *tradingstate.TradingStateDB, statedb *state.StateDB, ...) (error, bool)
- func (taox *TaoX) ProcessOrderPending(coinbase common.Address, chain consensus.ChainContext, ...) ([]tradingstate.TxDataMatch, map[common.Hash]tradingstate.MatchingResult)
- func (taox *TaoX) Protocols() []p2p.Protocol
- func (taox *TaoX) RollbackReorgTxMatch(txhash common.Hash) error
- func (taox *TaoX) SaveData()
- func (taox *TaoX) Start(server *p2p.Server) error
- func (taox *TaoX) Stop() error
- func (taox *TaoX) SyncDataToSDKNode(takerOrderInTx *tradingstate.OrderItem, txHash common.Hash, ...) error
- func (taox *TaoX) UpdateMediumPriceBeforeEpoch(epochNumber uint64, tradingStateDB *tradingstate.TradingStateDB, ...) error
- func (taox *TaoX) UpdateOrderCache(baseToken, quoteToken common.Address, orderHash common.Hash, ...)
- func (taox *TaoX) Version() uint64
Constants ¶
View Source
const ( ProtocolName = "taox" ProtocolVersion = uint64(1) ProtocolVersionStr = "1.0" MaximumTxMatchSize = 1000 )
View Source
const (
LimitThresholdOrderNonceInQueue = 100
)
Variables ¶
View Source
var ( ErrNoTopics = errors.New("missing topic(s)") ErrOrderNonceTooLow = errors.New("OrderNonce too low") ErrOrderNonceTooHigh = errors.New("OrderNonce too high") )
List of errors
View Source
var ( ErrNonceTooHigh = errors.New("nonce too high") ErrNonceTooLow = errors.New("nonce too low") )
View Source
var DefaultConfig = Config{
DataDir: "",
}
DefaultConfig represents (shocker!) the default configuration.
Functions ¶
func DoSettleBalance ¶
func DoSettleBalance(coinbase common.Address, takerOrder, makerOrder *tradingstate.OrderItem, settleBalance *tradingstate.SettleBalance, statedb *state.StateDB) error
func GetTradeQuantity ¶
func NewLDBEngine ¶
func NewLDBEngine(cfg *Config) *taoxDAO.BatchDatabase
func NewMongoDBEngine ¶
func NewMongoDBEngine(cfg *Config) *taoxDAO.MongoDatabase
Types ¶
type PublicTaoXAPI ¶
type PublicTaoXAPI struct {
// contains filtered or unexported fields
}
PublicTaoXAPI provides the taoX RPC service that can be use publicly without security implications.
func NewPublicTaoXAPI ¶
func NewPublicTaoXAPI(t *TaoX) *PublicTaoXAPI
NewPublicTaoXAPI create a new RPC taoX service.
type TaoX ¶
type TaoX struct { Triegc *prque.Prque // Priority queue mapping block numbers to tries to gc StateCache tradingstate.Database // State database to reuse between imports (contains state cache) *taox_state.TradingStateDB // contains filtered or unexported fields }
func (*TaoX) ApplyOrder ¶
func (taox *TaoX) ApplyOrder(coinbase common.Address, chain consensus.ChainContext, statedb *state.StateDB, tradingStateDB *tradingstate.TradingStateDB, orderBook common.Hash, order *tradingstate.OrderItem) ([]map[string]string, []*tradingstate.OrderItem, error)
func (*TaoX) CommitOrder ¶
func (taox *TaoX) CommitOrder(coinbase common.Address, chain consensus.ChainContext, statedb *state.StateDB, tradingStateDB *tradingstate.TradingStateDB, orderBook common.Hash, order *tradingstate.OrderItem) ([]map[string]string, []*tradingstate.OrderItem, error)
func (*TaoX) GetLevelDB ¶
func (*TaoX) GetMongoDB ¶
func (*TaoX) GetStateCache ¶
func (taox *TaoX) GetStateCache() tradingstate.Database
func (*TaoX) GetTokenDecimal ¶
func (*TaoX) GetTradingState ¶
func (taox *TaoX) GetTradingState(block *types.Block, author common.Address) (*tradingstate.TradingStateDB, error)
func (*TaoX) GetTradingStateRoot ¶
func (*TaoX) HasTradingState ¶
func (*TaoX) LogEpochPrice ¶
func (taox *TaoX) LogEpochPrice(epochNumber uint64, epochPriceResult map[common.Hash]*big.Int) error
put average price of epoch to mongodb for tracking liquidation trades epochPriceResult: a map of epoch average price, key is orderbook hash , value is epoch average price orderbook hash genereted from baseToken, quoteToken at tao2/taox/tradingstate/common.go:214
func (*TaoX) ProcessCancelOrder ¶
func (taox *TaoX) ProcessCancelOrder(tradingStateDB *tradingstate.TradingStateDB, statedb *state.StateDB, chain consensus.ChainContext, coinbase common.Address, orderBook common.Hash, order *tradingstate.OrderItem) (error, bool)
func (*TaoX) ProcessOrderPending ¶
func (taox *TaoX) ProcessOrderPending(coinbase common.Address, chain consensus.ChainContext, pending map[common.Address]types.OrderTransactions, statedb *state.StateDB, taoXstatedb *tradingstate.TradingStateDB) ([]tradingstate.TxDataMatch, map[common.Hash]tradingstate.MatchingResult)
func (*TaoX) RollbackReorgTxMatch ¶
func (*TaoX) SyncDataToSDKNode ¶
func (taox *TaoX) SyncDataToSDKNode(takerOrderInTx *tradingstate.OrderItem, txHash common.Hash, txMatchTime time.Time, statedb *state.StateDB, trades []map[string]string, rejectedOrders []*tradingstate.OrderItem, dirtyOrderCount *uint64) error
there are 3 tasks need to complete to update data in SDK nodes after matching
- txMatchData.Order: order has been processed. This order should be put to `orders` collection with status sdktypes.OrderStatusOpen
- txMatchData.Trades: includes information of matched orders. a. PutObject them to `trades` collection b. Update status of regrading orders to sdktypes.OrderStatusFilled
func (*TaoX) UpdateMediumPriceBeforeEpoch ¶
func (taox *TaoX) UpdateMediumPriceBeforeEpoch(epochNumber uint64, tradingStateDB *tradingstate.TradingStateDB, statedb *state.StateDB) error
func (*TaoX) UpdateOrderCache ¶
func (taox *TaoX) UpdateOrderCache(baseToken, quoteToken common.Address, orderHash common.Hash, txhash common.Hash, lastState tradingstate.OrderHistoryItem)
Directories ¶
Path | Synopsis |
---|---|
Package state provides a caching layer atop the Ethereum state trie.
|
Package state provides a caching layer atop the Ethereum state trie. |
Click to show internal directories.
Click to hide internal directories.