gateway

package
v0.0.0-...-491e088 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2019 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventPostfixReq         = "_req"
	EventPostfixRes         = "_res"
	EventPostfixEnd         = "_end"
	DefaultCronSpec3Second  = "0/3 * * * * *"
	DefaultCronSpec5Second  = "0/5 * * * * *"
	DefaultCronSpec10Second = "0/10 * * * * *"
	DefaultCronSpec5Minute  = "0 */5 * * * *"
)
View Source
const DefaultCapCurrency = "CNY"
View Source
const P2P_50001 = "50001"
View Source
const P2P_50002 = "50002"
View Source
const P2P_50003 = "50003"
View Source
const P2P_50004 = "50004"
View Source
const P2P_50005 = "50005"
View Source
const P2P_50006 = "50006"
View Source
const P2P_50008 = "50008"
View Source
const PendingTxPreKey = "PENDING_TX_"
View Source
const SYS_10001 = "10001"

Variables

View Source
var EventTypeRoute = map[string]InvokeInfo{
	// contains filtered or unexported fields
}

Functions

func GetPow

func GetPow(v uint8, r types.Bytes32, s types.Bytes32, powNonce uint64) *big.Int

func HandleInputOrder

func HandleInputOrder(input eventemitter.EventData) (orderHash string, err error)

func HandleOrder

func HandleOrder(input eventemitter.EventData) error

func Uint64ToByteArray

func Uint64ToByteArray(src uint64) []byte

Types

type AccountJson

type AccountJson struct {
	DelegateAddress string  `json:"delegateAddress"`
	Address         string  `json:"owner"`
	Tokens          []Token `json:"tokens"`
}

type AskBid

type AskBid struct {
	Buy  [][]string `json:"buy"`
	Sell [][]string `json:"sell"`
}

type BaseFilter

type BaseFilter struct {
	MinLrcFee             *big.Int
	MinLrcHold            int64
	MinSplitPercentage    float64
	MaxSplitPercentage    float64
	MaxPrice              *big.Int
	MinTokeSAmount        map[string]*big.Int
	MinTokenSUsdAmount    float64
	MaxValidSinceInterval int64
}

type BusinessType

type BusinessType int

type CommonTokenRequest

type CommonTokenRequest struct {
	DelegateAddress string `json:"delegateAddress"`
	Owner           string `json:"owner"`
}

type CutoffFilter

type CutoffFilter struct {
	// contains filtered or unexported fields
}

type CutoffRequest

type CutoffRequest struct {
	Address         string `json:"address"`
	DelegateAddress string `json:"delegateAddress"`
	BlockNumber     string `json:"blockNumber"`
}

type Depth

type Depth struct {
	DelegateAddress string `json:"delegateAddress"`
	Market          string `json:"market"`
	Depth           AskBid `json:"depth"`
}

type DepthElement

type DepthElement struct {
	Price  string   `json:"price"`
	Size   *big.Rat `json:"size"`
	Amount *big.Rat `json:"amount"`
}

type DepthQuery

type DepthQuery struct {
	DelegateAddress string `json:"delegateAddress"`
	Market          string `json:"market"`
}

type EstimatedAllocatedAllowanceQuery

type EstimatedAllocatedAllowanceQuery struct {
	DelegateAddress string `json:"delegateAddress"`
	Owner           string `json: "owner"`
	Token           string `json: "token"`
}

type EthForwarder

type EthForwarder struct {
}

func (*EthForwarder) Call

func (e *EthForwarder) Call(ethCall *ethaccessor.CallArg, blockNumber string) (result string, err error)

func (*EthForwarder) GetBalance

func (e *EthForwarder) GetBalance(address, blockNumber string) (result string, err error)

func (*EthForwarder) GetTransactionCount

func (e *EthForwarder) GetTransactionCount(address, blockNumber string) (result string, err error)

func (*EthForwarder) SendRawTransaction

func (e *EthForwarder) SendRawTransaction(tx string) (result string, err error)

type FillQuery

type FillQuery struct {
	DelegateAddress string `json:"delegateAddress"`
	Market          string `json:"market"`
	Owner           string `json:"owner"`
	OrderHash       string `json:"orderHash"`
	RingHash        string `json:"ringHash"`
	PageIndex       int    `json:"pageIndex"`
	PageSize        int    `json:"pageSize"`
	Side            string `json:"side"`
	OrderType       string `json:"orderType"`
}

type Filter

type Filter interface {
	// contains filtered or unexported methods
}

type Gateway

type Gateway struct {
	// contains filtered or unexported fields
}

type IPFSPubService

type IPFSPubService interface {
	PublishOrder(order types.Order) error
}

type IPFSPubServiceImpl

type IPFSPubServiceImpl struct {
	// contains filtered or unexported fields
}

func NewIPFSPubService

func NewIPFSPubService(options *config.IpfsOptions) *IPFSPubServiceImpl

func (*IPFSPubServiceImpl) PublishOrder

func (p *IPFSPubServiceImpl) PublishOrder(order types.Order) error

type IPFSSubService

type IPFSSubService interface {

	// Register register topic in options and start ipfs sub client
	Register(topic string) error

	// Unregister unregister topic from options and stop ipfs sub client
	Unregister(topic string) error

	// Start default start ipfs sub client
	Start()

	// Stop
	Stop()

	// Restart
	Restart()
}

type IPFSSubServiceImpl

type IPFSSubServiceImpl struct {
	// contains filtered or unexported fields
}

func NewIPFSSubService

func NewIPFSSubService(options config.IpfsOptions) *IPFSSubServiceImpl

func (*IPFSSubServiceImpl) Register

func (l *IPFSSubServiceImpl) Register(topic string) error

func (*IPFSSubServiceImpl) Restart

func (l *IPFSSubServiceImpl) Restart()

func (*IPFSSubServiceImpl) Start

func (l *IPFSSubServiceImpl) Start()

func (*IPFSSubServiceImpl) Stop

func (l *IPFSSubServiceImpl) Stop()

func (*IPFSSubServiceImpl) Unregister

func (l *IPFSSubServiceImpl) Unregister(topic string) error

type InvokeInfo

type InvokeInfo struct {
	MethodName string
	Query      interface{}
	// contains filtered or unexported fields
}

type JsonrpcService

type JsonrpcService interface {
	Start(port string)
	Stop()
}

type JsonrpcServiceImpl

type JsonrpcServiceImpl struct {
	// contains filtered or unexported fields
}

func NewJsonrpcService

func NewJsonrpcService(port string, walletService *WalletServiceImpl) *JsonrpcServiceImpl

func (*JsonrpcServiceImpl) Ping

func (*JsonrpcServiceImpl) Ping(val string, val2 int) (res string, err error)

func (*JsonrpcServiceImpl) Start

func (j *JsonrpcServiceImpl) Start()

type LatestFill

type LatestFill struct {
	CreateTime int64   `json:"createTime"`
	Price      float64 `json:"price"`
	Amount     float64 `json:"amount"`
	Side       string  `json:"side"`
	RingHash   string  `json:"ringHash"`
	LrcFee     string  `json:"lrcFee"`
	SplitS     string  `json:"splitS"`
	SplitB     string  `json:"splitB"`
}

type OrderJsonResult

type OrderJsonResult struct {
	RawOrder         RawOrderJsonResult `json:"originalOrder"`
	DealtAmountS     string             `json:"dealtAmountS"`
	DealtAmountB     string             `json:"dealtAmountB"`
	CancelledAmountS string             `json:"cancelledAmountS"`
	CancelledAmountB string             `json:"cancelledAmountB"`
	Status           string             `json:"status"`
}

type OrderQuery

type OrderQuery struct {
	Status          string `json:"status"`
	PageIndex       int    `json:"pageIndex"`
	PageSize        int    `json:"pageSize"`
	DelegateAddress string `json:"delegateAddress"`
	Owner           string `json:"owner"`
	Market          string `json:"market"`
	OrderHash       string `json:"orderHash"`
	Side            string `json:"side"`
	OrderType       string `json:"orderType"`
}

type P2PRingRequest

type P2PRingRequest struct {
	RawTx string `json:"rawTx"`
	//Taker          *types.OrderJsonRequest `json:"taker"`
	TakerOrderHash string `json:"takerOrderHash"`
	MakerOrderHash string `json:"makerOrderHash"`
}

type PageResult

type PageResult struct {
	Data      []interface{} `json:"data"`
	PageIndex int           `json:"pageIndex"`
	PageSize  int           `json:"pageSize"`
	Total     int           `json:"total"`
}

type Portfolio

type Portfolio struct {
	Token      string `json:"token"`
	Amount     string `json:"amount"`
	Percentage string `json:"percentage"`
}

type PowFilter

type PowFilter struct {
	Difficulty *big.Int
}

type PriceQuote

type PriceQuote struct {
	Currency string       `json:"currency"`
	Tokens   []TokenPrice `json:"tokens"`
}

type PriceQuoteQuery

type PriceQuoteQuery struct {
	Currency string `json:"currency"`
}

type RawOrderJsonResult

type RawOrderJsonResult struct {
	Protocol        string `json:"protocol"`        // 智能合约地址
	DelegateAddress string `json:"delegateAddress"` // 智能合约地址
	Owner           string `json:"address"`
	Hash            string `json:"hash"`
	TokenS          string `json:"tokenS"`  // 卖出erc20代币智能合约地址
	TokenB          string `json:"tokenB"`  // 买入erc20代币智能合约地址
	AmountS         string `json:"amountS"` // 卖出erc20代币数量上限
	AmountB         string `json:"amountB"` // 买入erc20代币数量上限
	ValidSince      string `json:"validSince"`
	ValidUntil      string `json:"validUntil"` // 订单过期时间
	//Salt                  string `json:"salt"`
	LrcFee                string `json:"lrcFee"` // 交易总费用,部分成交的费用按该次撮合实际卖出代币额与比例计算
	BuyNoMoreThanAmountB  bool   `json:"buyNoMoreThanAmountB"`
	MarginSplitPercentage string `json:"marginSplitPercentage"` // 不为0时支付给交易所的分润比例,否则视为100%
	V                     string `json:"v"`
	R                     string `json:"r"`
	S                     string `json:"s"`
	WalletAddress         string `json:"walletAddress" gencodec:"required"`
	AuthAddr              string `json:"authAddr" gencodec:"required"`       //
	AuthPrivateKey        string `json:"authPrivateKey" gencodec:"required"` //
	Market                string `json:"market"`
	Side                  string `json:"side"`
	CreateTime            int64  `json:"createTime"`
	OrderType             string `json:"orderType"`
}

type RingMinedDetail

type RingMinedDetail struct {
	RingInfo RingMinedInfo   `json:"ringInfo"`
	Fills    []dao.FillEvent `json:"fills"`
}

type RingMinedInfo

type RingMinedInfo struct {
	ID                 int                 `json:"id"`
	Protocol           string              `json:"protocol"`
	DelegateAddress    string              `json:"delegateAddress"`
	RingIndex          string              `json:"ringIndex"`
	RingHash           string              `json:"ringHash"`
	TxHash             string              `json:"txHash"`
	Miner              string              `json:"miner"`
	FeeRecipient       string              `json:"feeRecipient"`
	IsRinghashReserved bool                `json:"isRinghashReserved"`
	BlockNumber        int64               `json:"blockNumber"`
	TotalLrcFee        string              `json:"totalLrcFee"`
	TotalSplitFee      map[string]*big.Int `json:"totalSplitFee"`
	TradeAmount        int                 `json:"tradeAmount"`
	Time               int64               `json:"timestamp"`
}

type RingMinedQuery

type RingMinedQuery struct {
	DelegateAddress string `json:"delegateAddress"`
	ProtocolAddress string `json:"protocolAddress"`
	RingIndex       string `json:"ringIndex"`
	PageIndex       int    `json:"pageIndex"`
	PageSize        int    `json:"pageSize"`
}

type Server

type Server struct {
	socketio.Server
}

func NewServer

func NewServer(s socketio.Server) Server

func (Server) ServeHTTP

func (s Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

type SignFilter

type SignFilter struct {
}

type SingleDelegateAddress

type SingleDelegateAddress struct {
	DelegateAddress string `json:"delegateAddress"`
}

type SingleMarket

type SingleMarket struct {
	Market string `json:"market"`
}

type SingleOwner

type SingleOwner struct {
	Owner string `json:"owner"`
}

type SocketClient

type SocketClient struct {
	// contains filtered or unexported fields
}

type SocketIOJsonResp

type SocketIOJsonResp struct {
	Error string      `json:"error"`
	Code  string      `json:"code"`
	Data  interface{} `json:"data"`
}

type SocketIOService

type SocketIOService interface {
	Start(port string)
	Stop()
}

type SocketIOServiceImpl

type SocketIOServiceImpl struct {
	// contains filtered or unexported fields
}

func NewSocketIOService

func NewSocketIOService(port string, walletService WalletServiceImpl) *SocketIOServiceImpl

func (*SocketIOServiceImpl) EmitNowByEventType

func (so *SocketIOServiceImpl) EmitNowByEventType(bk string, v socketio.Conn, bv string)

func (*SocketIOServiceImpl) Start

func (so *SocketIOServiceImpl) Start()

type SocketNode

type SocketNode struct {
	// contains filtered or unexported fields
}

type Token

type Token struct {
	Token     string `json:"symbol"`
	Balance   string `json:"balance"`
	Allowance string `json:"allowance"`
}

type TokenFilter

type TokenFilter struct {
	AllowTokens  map[common.Address]bool
	DeniedTokens map[common.Address]bool
}

type TokenPrice

type TokenPrice struct {
	Token string  `json:"symbol"`
	Price float64 `json:"price"`
}

type TransactionQuery

type TransactionQuery struct {
	ThxHash   string   `json:"thxHash"`
	Owner     string   `json:"owner"`
	Symbol    string   `json: "symbol"`
	Status    string   `json: "status"`
	TxType    string   `json:"txType"`
	TrxHashes []string `json:"trxHashes"`
	PageIndex int      `json:"pageIndex"`
	PageSize  int      `json:"pageSize"`
}

type TrendQuery

type TrendQuery struct {
	Market   string `json:"market"`
	Interval string `json:"interval"`
}

type TxNotify

type TxNotify struct {
	Hash     string `json:"hash"`
	Nonce    string `json:"nonce"`
	From     string `json:"from"`
	To       string `json:"to"`
	Value    string `json:"value"`
	GasPrice string `json:"gasPrice"`
	Gas      string `json:"gas"`
	Input    string `json:"input"`
	R        string `json:"r"`
	S        string `json:"s"`
	V        string `json:"v"`
}

type WalletServiceImpl

type WalletServiceImpl struct {
	// contains filtered or unexported fields
}

func NewWalletService

func NewWalletService(trendManager market.TrendManager, orderManager ordermanager.OrderManager, accountManager market.AccountManager,
	capProvider marketcap.MarketCapProvider, collector market.CollectorImpl, rds dao.RdsService, oldWethAddress string) *WalletServiceImpl

func (*WalletServiceImpl) GetBalance

func (w *WalletServiceImpl) GetBalance(balanceQuery CommonTokenRequest) (res AccountJson, err error)

func (*WalletServiceImpl) GetContracts

func (w *WalletServiceImpl) GetContracts() (contracts map[string][]string, err error)

func (*WalletServiceImpl) GetCutoff

func (w *WalletServiceImpl) GetCutoff(query CutoffRequest) (result int64, err error)

func (*WalletServiceImpl) GetDepth

func (w *WalletServiceImpl) GetDepth(query DepthQuery) (res Depth, err error)

func (*WalletServiceImpl) GetEstimateGasPrice

func (w *WalletServiceImpl) GetEstimateGasPrice() (result string, err error)

func (*WalletServiceImpl) GetEstimatedAllocatedAllowance

func (w *WalletServiceImpl) GetEstimatedAllocatedAllowance(query EstimatedAllocatedAllowanceQuery) (frozenAmount string, err error)

func (*WalletServiceImpl) GetFills

func (w *WalletServiceImpl) GetFills(query FillQuery) (dao.PageResult, error)

func (*WalletServiceImpl) GetFrozenLRCFee

func (w *WalletServiceImpl) GetFrozenLRCFee(query SingleOwner) (frozenAmount string, err error)

func (*WalletServiceImpl) GetLatestFills

func (w *WalletServiceImpl) GetLatestFills(query FillQuery) ([]LatestFill, error)

func (*WalletServiceImpl) GetLooprSupportedMarket

func (w *WalletServiceImpl) GetLooprSupportedMarket() (markets []string, err error)

func (*WalletServiceImpl) GetLooprSupportedTokens

func (w *WalletServiceImpl) GetLooprSupportedTokens() (markets []types.Token, err error)

func (*WalletServiceImpl) GetOldVersionWethBalance

func (w *WalletServiceImpl) GetOldVersionWethBalance(owner SingleOwner) (res string, err error)

func (*WalletServiceImpl) GetOrderByHash

func (w *WalletServiceImpl) GetOrderByHash(query OrderQuery) (order OrderJsonResult, err error)

func (*WalletServiceImpl) GetOrders

func (w *WalletServiceImpl) GetOrders(query *OrderQuery) (res PageResult, err error)

func (*WalletServiceImpl) GetPendingRawTxByHash

func (w *WalletServiceImpl) GetPendingRawTxByHash(query TransactionQuery) (result TxNotify, err error)

func (*WalletServiceImpl) GetPendingTransactions

func (w *WalletServiceImpl) GetPendingTransactions(query SingleOwner) (result []txtyp.TransactionJsonResult, err error)

func (*WalletServiceImpl) GetPortfolio

func (w *WalletServiceImpl) GetPortfolio(query SingleOwner) (res []Portfolio, err error)

func (*WalletServiceImpl) GetPriceQuote

func (w *WalletServiceImpl) GetPriceQuote(query PriceQuoteQuery) (result PriceQuote, err error)

func (*WalletServiceImpl) GetRingMined

func (w *WalletServiceImpl) GetRingMined(query RingMinedQuery) (res dao.PageResult, err error)

func (*WalletServiceImpl) GetRingMinedDetail

func (w *WalletServiceImpl) GetRingMinedDetail(query RingMinedQuery) (res RingMinedDetail, err error)

func (*WalletServiceImpl) GetSupportedMarket

func (w *WalletServiceImpl) GetSupportedMarket() (markets []string, err error)

func (*WalletServiceImpl) GetSupportedTokens

func (w *WalletServiceImpl) GetSupportedTokens() (markets []types.Token, err error)

func (*WalletServiceImpl) GetTicker

func (w *WalletServiceImpl) GetTicker() (res []market.Ticker, err error)

func (*WalletServiceImpl) GetTickers

func (w *WalletServiceImpl) GetTickers(mkt SingleMarket) (result map[string]market.Ticker, err error)

func (*WalletServiceImpl) GetTransactions

func (w *WalletServiceImpl) GetTransactions(query TransactionQuery) (PageResult, error)

func (*WalletServiceImpl) GetTransactionsByHash

func (w *WalletServiceImpl) GetTransactionsByHash(query TransactionQuery) (result []txtyp.TransactionJsonResult, err error)

func (*WalletServiceImpl) GetTrend

func (w *WalletServiceImpl) GetTrend(query TrendQuery) (res []market.Trend, err error)

func (*WalletServiceImpl) NotifyTransactionSubmitted

func (w *WalletServiceImpl) NotifyTransactionSubmitted(txNotify TxNotify) (result string, err error)

func (*WalletServiceImpl) SubmitOrder

func (w *WalletServiceImpl) SubmitOrder(order *types.OrderJsonRequest) (res string, err error)

func (*WalletServiceImpl) SubmitRingForP2P

func (w *WalletServiceImpl) SubmitRingForP2P(p2pRing P2PRingRequest) (res string, err error)

func (*WalletServiceImpl) TestPing

func (w *WalletServiceImpl) TestPing(input int) (resp []byte, err error)

func (*WalletServiceImpl) UnlockWallet

func (w *WalletServiceImpl) UnlockWallet(owner SingleOwner) (result string, err error)

type WebsocketRequest

type WebsocketRequest map[string]string

type WebsocketService

type WebsocketService interface {
	Start(port string)
	Stop()
}

type WebsocketServiceImpl

type WebsocketServiceImpl struct {
	// contains filtered or unexported fields
}

func NewWebsocketService

func NewWebsocketService(port string, trendManager market.TrendManager, accountManager market.AccountManager, capProvider marketcap.MarketCapProvider) *WebsocketServiceImpl

func (*WebsocketServiceImpl) Start

func (ws *WebsocketServiceImpl) Start()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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