core

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DecByteCount = 40
	BUY          = 1
	SELL         = 2
	GTE          = 3
	LIMIT        = 2
)
View Source
const (
	BlockInfoKey           = "blockinfo"
	SlashKey               = "slash"
	TickerKey              = "ticker"
	KlineKey               = "kline"
	DepthKey               = "depth"
	OptionKey              = "option"
	DepthDelta             = "depth_delta"
	DepthChange            = "depth_change"
	DepthFull              = "depth_full"
	DealKey                = "deal"
	BancorKey              = "bancor"
	BancorTradeKey         = "bancor-trade"
	BancorDealKey          = "bancor-deal"
	CommentKey             = "comment"
	CreateMarketInfoKey    = "create_market"
	OrderKey               = "order"
	IncomeKey              = "income"
	UnbondingKey           = "unbonding"
	RedelegationKey        = "redelegation"
	UnlockKey              = "unlock"
	TxKey                  = "txs"
	LockedKey              = "send_lock_coins"
	DelegationRewardsKey   = "delegation_rewards"
	ValidatorCommissionKey = "validator_commission"
)
View Source
const (
	Type    = "type"
	Payload = "payload"
)
View Source
const (
	CreateOrderKey = "create_order"
	FillOrderKey   = "fill_order"
	CancelOrderKey = "cancel_order"
)
View Source
const (
	MaxCount     = 1024
	DumpVersion  = byte(0)
	DumpInterval = 1000
	DumpMinTime  = 10 * time.Minute
	//These bytes are used as the first byte in key
	//The format of different kinds of keys are listed below:
	CandleStickByte = byte(0x10) //-, ([]byte(market), []byte{0, timespan}...), 0, currBlockTime, hub.sid, lastByte=0
	DealByte        = byte(0x12) //-, []byte(market), 0, currBlockTime, hub.sid, lastByte=0
	OrderByte       = byte(0x14) //-, []byte(addr), 0, currBlockTime, hub.sid, lastByte=
	//                                                          CreateOrderEndByte,FillOrderEndByte,CancelOrderEndByte
	BancorInfoByte   = byte(0x16) //-, []byte(market), 0, currBlockTime, hub.sid, lastByte=0
	BancorTradeByte  = byte(0x18) //-, []byte(addr), 0, currBlockTime, hub.sid, lastByte=0
	IncomeByte       = byte(0x1A) //-, []byte(addr), 0, currBlockTime, hub.sid, lastByte=0
	TxByte           = byte(0x1C) //-, []byte(addr), 0, currBlockTime, hub.sid, lastByte=0
	CommentByte      = byte(0x1E) //-, []byte(token), 0, currBlockTime, hub.sid, lastByte=0
	BlockHeightByte  = byte(0x20) //-, heightBytes
	DetailByte       = byte(0x22) //([]byte{DetailByte}, []byte(v.Hash), currBlockTime)
	SlashByte        = byte(0x24) //-, []byte{}, 0, currBlockTime, hub.sid, lastByte=0
	LatestHeightByte = byte(0x26) //-
	BancorDealByte   = byte(0x28) //-, []byte(market), 0, currBlockTime, hub.sid, lastByte=0
	RedelegationByte = byte(0x30) //-, []byte(token), 0, completion time, hub.sid, lastByte=0
	UnbondingByte    = byte(0x32) //-, []byte(token), 0, completion time, hub.sid, lastByte=0
	UnlockByte       = byte(0x34) //-, []byte(addr), 0, currBlockTime, hub.sid, lastByte=0
	LockedByte       = byte(0x36) //-, []byte(addr), 0, currBlockTime, hub.sid, lastByte=0
	DonationByte     = byte(0x38) //-, []byte{}, 0, currBlockTime, hub.sid, lastByte=0
	DelistByte       = byte(0x3A) //-, []byte(market), 0, currBlockTime, hub.sid, lastByte=0

	// Used to store meta information
	OffsetByte = byte(0xF0)
	DumpByte   = byte(0xF1)

	// Used to indicate query types, not used in the keys in rocksdb
	DelistsByte         = byte(0x3B)
	CreateOrderOnlyByte = byte(0x40)
	FillOrderOnlyByte   = byte(0x42)
	CancelOrderOnlyByte = byte(0x44)

	// Later add key
	CreateMarketByte        = byte(0x46)
	ValidatorCommissionByte = byte(0x48)
	DelegatorRewardsByte    = byte(0x50)
)
View Source
const (
	CreateOrderEndByte = byte('c')
	FillOrderEndByte   = byte('f')
	CancelOrderEndByte = byte('d')
	Minute             = byte(0x10)
	Hour               = byte(0x20)
	Day                = byte(0x30)
	MinuteStr          = "1min"
	HourStr            = "1hour"
	DayStr             = "1day"
	CreateOrderStr     = "create"
	FillOrderStr       = "fill"
	CancelOrderStr     = "cancel"
)
View Source
const (
	SeparateArgu = ":"
	MaxArguNum   = 3
)
View Source
const MinuteNumInDay = 24 * 60

Variables

This section is empty.

Functions

func BigEndianBytesToInt64

func BigEndianBytesToInt64(bz []byte) int64

func GetSpanFromSpanStr

func GetSpanFromSpanStr(spanStr string) byte

func GetTopicAndParams added in v0.2.0

func GetTopicAndParams(subscriptionTopic string) (topic string, params []string, err error)

func Int64ToBigEndianBytes added in v0.2.6

func Int64ToBigEndianBytes(n int64) []byte

Types

type AllOrderInfo added in v0.0.19

type AllOrderInfo struct {
	CreateMap map[string]CreateOrderInfo
	FillMap   map[string]FillOrderInfo
	CancelMap map[string]CancelOrderInfo
}

type CancelOrderInfo

type CancelOrderInfo struct {
	OrderID     string  `json:"order_id"`
	TradingPair string  `json:"trading_pair"`
	Height      int64   `json:"height"`
	Side        byte    `json:"side"`
	Price       sdk.Dec `json:"price"`

	// Del infos
	DelReason string `json:"del_reason"`

	// Fields of amount
	UsedCommission int64 `json:"used_commission"`
	LeftStock      int64 `json:"left_stock"`
	RemainAmount   int64 `json:"remain_amount"`
	DealStock      int64 `json:"deal_stock"`
	DealMoney      int64 `json:"deal_money"`

	TxHash string `json:"tx_hash,omitempty"`

	UsedFeatureFee    int64  `json:"used_feature_fee,omitempty"`
	RebateAmount      int64  `json:"rebate_amount,omitempty"`
	RebateRefereeAddr string `json:"rebate_referee_addr,omitempty"`
}

someone who has created an order before, but now he/she wants to cancel it

type CandleStick

type CandleStick struct {
	OpenPrice      sdk.Dec `json:"open"`
	ClosePrice     sdk.Dec `json:"close"`
	HighPrice      sdk.Dec `json:"high"`
	LowPrice       sdk.Dec `json:"low"`
	TotalDeal      sdk.Int `json:"total"`
	EndingUnixTime int64   `json:"unix_time"`
	TimeSpan       string  `json:"time_span"`
	Market         string  `json:"market"`
}

push candle stick msg to ws

type CandleStickManager

type CandleStickManager struct {
	CsrMap        map[string]*CandleStickRecord `json:"csr_map"`
	LastBlockTime time.Time                     `json:"last_block_time"`
}

Manager of the CandleStickRecords for all markets

func NewCandleStickManager

func NewCandleStickManager(markets []string) CandleStickManager

func (*CandleStickManager) AddMarket

func (manager *CandleStickManager) AddMarket(market string)

func (*CandleStickManager) GetRecord

func (manager *CandleStickManager) GetRecord(Market string) *CandleStickRecord

func (*CandleStickManager) NewBlock

func (manager *CandleStickManager) NewBlock(currBlockTime time.Time) []*CandleStick

When a new blocks come at 't', flush out all the finished candle sticks util 't' The recorded manager.LastBlockTime will be used as the EndingTime of candle sticks

type CandleStickRecord

type CandleStickRecord struct {
	MinuteCS       [60]baseCandleStick `json:"minute_cs"`
	HourCS         [24]baseCandleStick `json:"hour_cs"`
	LastUpdateTime time.Time           `json:"last_update"` //the last time that 'Update' was invoked
	//the last time a non-empty minute/hour/day candle stick was "flushed out"
	//A candle stick is NOT "flushed out" UNTIL a new minute/hour/day comes
	LastMinuteCSTime int64 `json:"last_minute_cs_time"`
	LastHourCSTime   int64 `json:"last_hour_cs_time"`
	LastDayCSTime    int64 `json:"last_day_cs_time"`
	//the last price of a non-empty minute/hour/day candle stick
	LastMinutePrice sdk.Dec `json:"last_minute_price"`
	LastHourPrice   sdk.Dec `json:"last_hour_price"`
	LastDayPrice    sdk.Dec `json:"last_day_price"`
	Market          string  `json:"Market"`
}

Record the candle sticks within one day It can provide three granularities: minute, hour and day. If the client side wants other granularities, we need to merge several candle sticks into one.

func NewCandleStickRecord

func NewCandleStickRecord(market string) *CandleStickRecord

func (*CandleStickRecord) Update

func (csr *CandleStickRecord) Update(t time.Time, price sdk.Dec, amount int64)

Update when there is a new deal

type CandleStickSubscriber

type CandleStickSubscriber struct {
	PlainSubscriber
	TimeSpan string
}

func NewCandleStickSubscriber

func NewCandleStickSubscriber(id int64, timespan string) *CandleStickSubscriber

func (*CandleStickSubscriber) Detail

func (s *CandleStickSubscriber) Detail() interface{}

func (*CandleStickSubscriber) GetConn added in v0.0.2

func (s *CandleStickSubscriber) GetConn() *Conn

func (*CandleStickSubscriber) WriteMsg

func (s *CandleStickSubscriber) WriteMsg([]byte) error

type CommentRef

type CommentRef struct {
	ID           uint64  `json:"id"`
	RewardTarget string  `json:"reward_target"`
	RewardToken  string  `json:"reward_token"`
	RewardAmount int64   `json:"reward_amount"`
	Attitudes    []int32 `json:"attitudes"`
}

type Conn

type Conn struct {
	WsIfc WsInterface
	// contains filtered or unexported fields
}

Conn models the connection to a client through websocket

func NewConn

func NewConn(c WsInterface) *Conn

func (*Conn) Close added in v0.2.0

func (c *Conn) Close() error

func (*Conn) PingHandler added in v0.2.0

func (c *Conn) PingHandler() func(string) error

func (*Conn) ReadMsg added in v0.2.0

func (c *Conn) ReadMsg(manager *WebsocketManager) (message []byte, err error)

Since WsIfc.ReadMessage is blocking, this function is only used in the handleConn goroutine

func (*Conn) WriteMsg added in v0.0.19

func (c *Conn) WriteMsg(v []byte) error

type Consumer

type Consumer interface {
	ConsumeMessage(msgType string, bz []byte)
}

type CreateOrderInfo

type CreateOrderInfo struct {
	OrderID     string  `json:"order_id"`
	Sender      string  `json:"sender"`
	TradingPair string  `json:"trading_pair"`
	OrderType   byte    `json:"order_type"`
	Price       sdk.Dec `json:"price"`
	Quantity    int64   `json:"quantity"`
	Side        byte    `json:"side"`
	TimeInForce int     `json:"time_in_force"`
	FeatureFee  int64   `json:"feature_fee"` //Deprecated
	Height      int64   `json:"height"`
	FrozenFee   int64   `json:"frozen_fee"` //Deprecated
	Freeze      int64   `json:"freeze"`

	FrozenFeatureFee int64 `json:"frozen_feature_fee,omitempty"`
	FrozenCommission int64 `json:"frozen_commission,omitempty"`

	TxHash string `json:"tx_hash,omitempty"`
}

someone creates an order

type DeltaChangeEntry added in v0.2.0

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

type DepthDetails

type DepthDetails struct {
	TradingPair string        `json:"trading_pair"`
	Bids        []*PricePoint `json:"bids"`
	Asks        []*PricePoint `json:"asks"`
}

for the same trading pair, the bid prices and ask prices in this market

type DepthManager

type DepthManager struct {
	Updated map[string]*PricePoint //it records all the changed PricePoint during last block
	Side    string
	//following members are used for depth merging
	Levels                 []string
	CachedMulDecsForLevels []sdk.Dec
	LevelDepth             LevelsPricePoint
	// contains filtered or unexported fields
}

Manager for the depth information of one side of the order book: sell or buy

func NewDepthManager added in v0.2.0

func NewDepthManager(side string) *DepthManager

func (*DepthManager) AddLevel

func (dm *DepthManager) AddLevel(levelStr string) error

func (*DepthManager) DeltaChange

func (dm *DepthManager) DeltaChange(price sdk.Dec, amount sdk.Int)

The orderbook's entry at 'price' is delta-changed by amount positive amount for increment, negative amount for decrement

func (*DepthManager) DumpPricePoints

func (dm *DepthManager) DumpPricePoints() []*PricePoint

dump the PricePoints in ppMap for serialization

func (*DepthManager) EndBlock

func (dm *DepthManager) EndBlock() (woMerging map[string]*PricePoint, wiMerging map[string]map[string]*PricePoint)

Returns the changed PricePoints of last block, without and with merging Clear dm.Updated and dm.LevelDepth for the next block

func (*DepthManager) GetHighest

func (dm *DepthManager) GetHighest(n int) []*PricePoint

Returns the highest n PricePoints

func (*DepthManager) GetLowest

func (dm *DepthManager) GetLowest(n int) []*PricePoint

Returns the lowest n PricePoints

func (*DepthManager) Size

func (dm *DepthManager) Size() int

type DepthSubscriber

type DepthSubscriber struct {
	PlainSubscriber

	sync.Mutex
	// contains filtered or unexported fields
}

func NewDepthSubscriber

func NewDepthSubscriber(id int64, level string) *DepthSubscriber

func (*DepthSubscriber) ClearMsg added in v0.0.2

func (s *DepthSubscriber) ClearMsg()

func (*DepthSubscriber) CompareRet added in v0.0.2

func (s *DepthSubscriber) CompareRet(t *testing.T, actual []string)

func (*DepthSubscriber) Detail

func (s *DepthSubscriber) Detail() interface{}

func (*DepthSubscriber) GetConn added in v0.0.2

func (s *DepthSubscriber) GetConn() *Conn

func (*DepthSubscriber) WriteMsg

func (s *DepthSubscriber) WriteMsg(msg []byte) error

type Donation

type Donation struct {
	Sender string `json:"sender"`
	Amount string `json:"amount"`
}

type FillOrderInfo

type FillOrderInfo struct {
	OrderID     string  `json:"order_id"`
	TradingPair string  `json:"trading_pair"`
	Height      int64   `json:"height"`
	Side        byte    `json:"side"`
	Price       sdk.Dec `json:"price"`

	// These fields will change when order was filled/canceled.
	LeftStock int64   `json:"left_stock"`
	Freeze    int64   `json:"freeze"`
	DealStock int64   `json:"deal_stock"`
	DealMoney int64   `json:"deal_money"`
	CurrStock int64   `json:"curr_stock"`
	CurrMoney int64   `json:"curr_money"`
	FillPrice sdk.Dec `json:"fill_price"`
}

another guy fills someone's order

type HeightInfo added in v0.2.6

type HeightInfo struct {
	Height    uint64 `json:"height"`
	TimeStamp uint64 `json:"timestamp"`
}

type Hub

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

func NewHub

func NewHub(db dbm.DB, subMan SubscribeManager, interval int64, monitorInterval int64,
	keepRecent int64, initChainHeight int64, oldChainID string, upgradeHeight int64) (hub *Hub)

func (*Hub) AddLevel

func (hub *Hub) AddLevel(market, level string) error

func (*Hub) AddMarket

func (hub *Hub) AddMarket(market string)

func (*Hub) Close

func (hub *Hub) Close()

func (*Hub) ConsumeMessage

func (hub *Hub) ConsumeMessage(msgType string, bz []byte)

Record the Msgs in msgEntryList and handle them in batch after commit

func (*Hub) Dump

func (hub *Hub) Dump(hub4j *HubForJSON)

func (*Hub) GetAllOrderInfo added in v0.0.19

func (hub *Hub) GetAllOrderInfo() AllOrderInfo

func (*Hub) HasMarket

func (hub *Hub) HasMarket(market string) bool

func (*Hub) Load

func (hub *Hub) Load(hub4j *HubForJSON)

func (*Hub) LoadDumpData

func (hub *Hub) LoadDumpData() []byte

func (*Hub) LoadOffset

func (hub *Hub) LoadOffset(partition int32) int64

func (*Hub) Log

func (hub *Hub) Log(s string)

func (*Hub) PushBancorDealMsg added in v0.0.19

func (hub *Hub) PushBancorDealMsg(market string, bz []byte)

func (*Hub) PushBancorMsg added in v0.0.19

func (hub *Hub) PushBancorMsg(market string, bz []byte)

func (*Hub) PushBancorTradeInfoMsg added in v0.0.19

func (hub *Hub) PushBancorTradeInfoMsg(addr string, bz []byte)

func (*Hub) PushCancelOrderMsg added in v0.0.19

func (hub *Hub) PushCancelOrderMsg(addr string, bz []byte)

func (*Hub) PushCandleMsg added in v0.0.19

func (hub *Hub) PushCandleMsg(market string, bz []byte, timeSpan string)

TODO. Add test

func (*Hub) PushCommentMsg added in v0.0.19

func (hub *Hub) PushCommentMsg(token string, bz []byte)

func (*Hub) PushCreateOrderInfoMsg added in v0.0.19

func (hub *Hub) PushCreateOrderInfoMsg(addr string, bz []byte)

func (*Hub) PushDealInfoMsg added in v0.0.19

func (hub *Hub) PushDealInfoMsg(market string, bz []byte)

func (*Hub) PushDelegationRewardsMsg added in v0.2.6

func (hub *Hub) PushDelegationRewardsMsg(addr string, data []byte)

func (*Hub) PushDepthFullMsg added in v0.0.19

func (hub *Hub) PushDepthFullMsg(market string)

TODO, will check topic

func (*Hub) PushDepthMsg added in v0.0.19

func (hub *Hub) PushDepthMsg(data []byte, levelsData map[string][]byte)

TODO, will replace string with interface

func (*Hub) PushFillOrderInfoMsg added in v0.0.19

func (hub *Hub) PushFillOrderInfoMsg(addr string, bz []byte)

func (*Hub) PushHeightInfoMsg added in v0.0.19

func (hub *Hub) PushHeightInfoMsg(bz []byte)

func (*Hub) PushIncomeMsg added in v0.2.0

func (hub *Hub) PushIncomeMsg(receiver string, bz []byte)

func (*Hub) PushLockedCoinsMsg added in v0.0.19

func (hub *Hub) PushLockedCoinsMsg(addr string, bz []byte)

func (*Hub) PushMarketInfoMsg added in v0.2.6

func (hub *Hub) PushMarketInfoMsg(market string, bz []byte)

func (*Hub) PushRedelegationMsg added in v0.0.19

func (hub *Hub) PushRedelegationMsg(param TimeAndSidWithAddr)

func (*Hub) PushSlashMsg added in v0.0.19

func (hub *Hub) PushSlashMsg(bz []byte)

func (*Hub) PushTickerMsg added in v0.0.19

func (hub *Hub) PushTickerMsg(msg interface{})

func (*Hub) PushTxMsg added in v0.0.19

func (hub *Hub) PushTxMsg(addr string, bz []byte)

func (*Hub) PushUnbondingMsg added in v0.0.19

func (hub *Hub) PushUnbondingMsg(param TimeAndSidWithAddr)

func (*Hub) PushUnlockMsg added in v0.0.19

func (hub *Hub) PushUnlockMsg(addr string, bz []byte)

func (*Hub) PushValidatorCommissionMsg added in v0.2.6

func (hub *Hub) PushValidatorCommissionMsg(addr string, data []byte)

func (*Hub) QueryBancorDeal added in v0.0.19

func (hub *Hub) QueryBancorDeal(market string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryBancorInfo

func (hub *Hub) QueryBancorInfo(market string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryBancorTrade

func (hub *Hub) QueryBancorTrade(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryBancorTradeAboutToken

func (hub *Hub) QueryBancorTradeAboutToken(token, account string, time int64, sid int64, count int) (
	data []json.RawMessage, timesid []int64)

func (*Hub) QueryBlockInfo added in v0.2.6

func (hub *Hub) QueryBlockInfo() *HeightInfo

func (*Hub) QueryBlockTime

func (hub *Hub) QueryBlockTime(height int64, count int) []int64

func (*Hub) QueryCandleStick

func (hub *Hub) QueryCandleStick(market string, timespan byte, time int64, sid int64, count int) []json.RawMessage

func (*Hub) QueryComment

func (hub *Hub) QueryComment(token string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryDeal

func (hub *Hub) QueryDeal(market string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryDelist added in v0.0.20

func (hub *Hub) QueryDelist(market string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryDelists added in v0.0.20

func (hub *Hub) QueryDelists(time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryDepth

func (hub *Hub) QueryDepth(market string, count int) (sell []*PricePoint, buy []*PricePoint)

func (*Hub) QueryDonation

func (hub *Hub) QueryDonation(time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryIncome

func (hub *Hub) QueryIncome(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryIncomeAboutToken

func (hub *Hub) QueryIncomeAboutToken(token, account string, time int64, sid int64, count int) (
	data []json.RawMessage, timesid []int64)

func (*Hub) QueryLatestHeight

func (hub *Hub) QueryLatestHeight() int64

func (*Hub) QueryLocked

func (hub *Hub) QueryLocked(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryLockedAboutToken

func (hub *Hub) QueryLockedAboutToken(token, account string, time int64, sid int64, count int) (
	data []json.RawMessage, timesid []int64)

func (*Hub) QueryOrder

func (hub *Hub) QueryOrder(account string, time int64, sid int64, count int) (
	data []json.RawMessage, tags []byte, timesid []int64)

func (*Hub) QueryOrderAboutToken

func (hub *Hub) QueryOrderAboutToken(tag, token, account string, time int64, sid int64, count int) (
	data []json.RawMessage, tags []byte, timesid []int64)

func (*Hub) QueryRedelegation

func (hub *Hub) QueryRedelegation(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QuerySlash

func (hub *Hub) QuerySlash(time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryTickers

func (hub *Hub) QueryTickers(marketList []string) []*Ticker

func (*Hub) QueryTx

func (hub *Hub) QueryTx(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryTxAboutToken

func (hub *Hub) QueryTxAboutToken(token, account string, time int64, sid int64, count int) (
	data []json.RawMessage, timesid []int64)

func (*Hub) QueryTxByHashID

func (hub *Hub) QueryTxByHashID(hexHashID string) json.RawMessage

func (*Hub) QueryUnbonding

func (hub *Hub) QueryUnbonding(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryUnlock

func (hub *Hub) QueryUnlock(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

func (*Hub) QueryUnlockAboutToken

func (hub *Hub) QueryUnlockAboutToken(token, account string, time int64, sid int64, count int) (
	data []json.RawMessage, timesid []int64)

func (*Hub) StoreLeastHeight added in v0.2.6

func (hub *Hub) StoreLeastHeight()

Not safe for concurrency; Only be used in init

func (*Hub) UpdateOffset

func (hub *Hub) UpdateOffset(partition int32, offset int64)

type HubForJSON

type HubForJSON struct {
	Sid             int64                `json:"sid"`
	CSMan           CandleStickManager   `json:"csman"`
	TickerMap       map[string]*Ticker   `json:"ticker_map"`
	CurrBlockHeight int64                `json:"curr_block_height"`
	CurrBlockTime   int64                `json:"curr_block_time"`
	LastBlockTime   int64                `json:"last_block_time"`
	Markets         []*MarketInfoForJSON `json:"markets"`
}

to dump hub's in-memory state to json

type ImplSubscriber

type ImplSubscriber struct {
	Conn *Conn
	// contains filtered or unexported fields
}

func (ImplSubscriber) Detail

func (i ImplSubscriber) Detail() interface{}

func (ImplSubscriber) GetConn added in v0.0.2

func (i ImplSubscriber) GetConn() *Conn

func (ImplSubscriber) WriteMsg

func (i ImplSubscriber) WriteMsg(v []byte) error

type LevelsPricePoint added in v0.2.0

type LevelsPricePoint map[string]map[string]*PricePoint // [level][priceBigEndian][*PricePoint]

----------- encode data

type LockedCoin

type LockedCoin struct {
	Coin        sdk.Coin `json:"coin"`
	UnlockTime  int64    `json:"unlock_time"`
	FromAddress string   `json:"from_address,omitempty"`
	Supervisor  string   `json:"supervisor,omitempty"`
	Reward      int64    `json:"reward,omitempty"`
}

-------------------- other module info

type LockedCoins

type LockedCoins []LockedCoin

type LockedSendMsg

type LockedSendMsg struct {
	FromAddress string    `json:"from_address"`
	ToAddress   string    `json:"to_address"`
	Amount      sdk.Coins `json:"amount"`
	UnlockTime  int64     `json:"unlock_time"`
	Supervisor  string    `json:"supervisor,omitempty"`
	Reward      int64     `json:"reward,omitempty"`

	TxHash string `json:"tx_hash,omitempty"`
}

someone sends locked coins to another another person can only wait until the unlock time to use these coins

type MarketInfo added in v0.2.6

type MarketInfo struct {
	Stock          string `json:"stock"`
	Money          string `json:"money"`
	Creator        string `json:"creator"`
	PricePrecision byte   `json:"price_precision"`
	OrderPrecision byte   `json:"order_precision"`
}

-------------------------- market info, e.g. abc/cet

type MarketInfoForJSON

type MarketInfoForJSON struct {
	TkMan           *TickerManager `json:"tkman"`
	SellPricePoints []*PricePoint  `json:"sells"`
	BuyPricePoints  []*PricePoint  `json:"buys"`
}

type MocSubscribeManager

type MocSubscribeManager struct {
	SlashSubscribeInfo        []Subscriber
	HeightSubscribeInfo       []Subscriber
	TickerSubscribeInfo       []Subscriber
	CandleStickSubscribeInfo  map[string][]Subscriber
	DepthSubscribeInfo        map[string][]Subscriber
	DealSubscribeInfo         map[string][]Subscriber
	BancorInfoSubscribeInfo   map[string][]Subscriber
	CommentSubscribeInfo      map[string][]Subscriber
	OrderSubscribeInfo        map[string][]Subscriber
	BancorTradeSubscribeInfo  map[string][]Subscriber
	IncomeSubscribeInfo       map[string][]Subscriber
	UnbondingSubscribeInfo    map[string][]Subscriber
	RedelegationSubscribeInfo map[string][]Subscriber
	UnlockSubscribeInfo       map[string][]Subscriber
	TxSubscribeInfo           map[string][]Subscriber
	LockedSubcribeInfo        map[string][]Subscriber
	BancorDealSubscribeInfo   map[string][]Subscriber
	MarketSubscribeInfo       map[string][]Subscriber

	sync.Mutex
	PushList []pushInfo
}

func GetDepthSubscribeManeger

func GetDepthSubscribeManeger() *MocSubscribeManager

func GetSubscribeManager

func GetSubscribeManager(addr1, addr2 string) *MocSubscribeManager

func (*MocSubscribeManager) GetBancorDealSubscribeInfo added in v0.0.19

func (sm *MocSubscribeManager) GetBancorDealSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetBancorInfoSubscribeInfo

func (sm *MocSubscribeManager) GetBancorInfoSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetBancorTradeSubscribeInfo

func (sm *MocSubscribeManager) GetBancorTradeSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetCandleStickSubscribeInfo

func (sm *MocSubscribeManager) GetCandleStickSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetCommentSubscribeInfo

func (sm *MocSubscribeManager) GetCommentSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetDealSubscribeInfo

func (sm *MocSubscribeManager) GetDealSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetDelegationRewards added in v0.2.6

func (sm *MocSubscribeManager) GetDelegationRewards() map[string][]Subscriber

func (*MocSubscribeManager) GetDepthSubscribeInfo

func (sm *MocSubscribeManager) GetDepthSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetHeightSubscribeInfo

func (sm *MocSubscribeManager) GetHeightSubscribeInfo() []Subscriber

func (*MocSubscribeManager) GetIncomeSubscribeInfo

func (sm *MocSubscribeManager) GetIncomeSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetLockedSubscribeInfo

func (sm *MocSubscribeManager) GetLockedSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetMarketSubscribeInfo added in v0.2.6

func (sm *MocSubscribeManager) GetMarketSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetOrderSubscribeInfo

func (sm *MocSubscribeManager) GetOrderSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetRedelegationSubscribeInfo

func (sm *MocSubscribeManager) GetRedelegationSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetSlashSubscribeInfo

func (sm *MocSubscribeManager) GetSlashSubscribeInfo() []Subscriber

func (*MocSubscribeManager) GetTickerSubscribeInfo

func (sm *MocSubscribeManager) GetTickerSubscribeInfo() []Subscriber

func (*MocSubscribeManager) GetTxSubscribeInfo

func (sm *MocSubscribeManager) GetTxSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetUnbondingSubscribeInfo

func (sm *MocSubscribeManager) GetUnbondingSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetUnlockSubscribeInfo

func (sm *MocSubscribeManager) GetUnlockSubscribeInfo() map[string][]Subscriber

func (*MocSubscribeManager) GetValidatorCommissionInfo added in v0.2.6

func (sm *MocSubscribeManager) GetValidatorCommissionInfo() map[string][]Subscriber

func (*MocSubscribeManager) PushBancorDeal added in v0.0.19

func (sm *MocSubscribeManager) PushBancorDeal(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushBancorInfo

func (sm *MocSubscribeManager) PushBancorInfo(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushBancorTrade

func (sm *MocSubscribeManager) PushBancorTrade(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushCancelOrder

func (sm *MocSubscribeManager) PushCancelOrder(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushCandleStick

func (sm *MocSubscribeManager) PushCandleStick(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushComment

func (sm *MocSubscribeManager) PushComment(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushCreateMarket added in v0.2.6

func (sm *MocSubscribeManager) PushCreateMarket(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushCreateOrder

func (sm *MocSubscribeManager) PushCreateOrder(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushDeal

func (sm *MocSubscribeManager) PushDeal(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushDelegationRewards added in v0.2.6

func (sm *MocSubscribeManager) PushDelegationRewards(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushDepthFullMsg added in v0.2.0

func (sm *MocSubscribeManager) PushDepthFullMsg(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushDepthWithChange added in v0.0.2

func (sm *MocSubscribeManager) PushDepthWithChange(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushDepthWithDelta added in v0.0.2

func (sm *MocSubscribeManager) PushDepthWithDelta(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushFillOrder

func (sm *MocSubscribeManager) PushFillOrder(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushHeight

func (sm *MocSubscribeManager) PushHeight(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushIncome

func (sm *MocSubscribeManager) PushIncome(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushLockedSendMsg

func (sm *MocSubscribeManager) PushLockedSendMsg(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushRedelegation

func (sm *MocSubscribeManager) PushRedelegation(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushSlash

func (sm *MocSubscribeManager) PushSlash(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushTicker

func (sm *MocSubscribeManager) PushTicker(subscriber Subscriber, t []*Ticker)

func (*MocSubscribeManager) PushTx

func (sm *MocSubscribeManager) PushTx(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushUnbonding

func (sm *MocSubscribeManager) PushUnbonding(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushUnlock

func (sm *MocSubscribeManager) PushUnlock(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) PushValidatorCommissionInfo added in v0.2.6

func (sm *MocSubscribeManager) PushValidatorCommissionInfo(subscriber Subscriber, info []byte)

func (*MocSubscribeManager) SetSkipOption

func (sm *MocSubscribeManager) SetSkipOption(isSkip bool)

type MsgBancorInfoForKafka

type MsgBancorInfoForKafka struct {
	Owner              string `json:"owner"`
	Stock              string `json:"stock"`
	Money              string `json:"money"`
	InitPrice          string `json:"init_price"`
	MaxSupply          string `json:"max_supply"`
	StockPrecision     string `json:"stock_precision,omitempty"`
	MaxPrice           string `json:"max_price"`
	MaxMoney           string `json:"max_money,omitempty"`
	AR                 string `json:"ar,omitempty"`
	CurrentPrice       string `json:"current_price"`
	StockInPool        string `json:"stock_in_pool"`
	MoneyInPool        string `json:"money_in_pool"`
	EarliestCancelTime int64  `json:"earliest_cancel_time"`
}

----------- bancor info someone uses bancor to create markets automatically

type MsgBancorTradeInfoForKafka

type MsgBancorTradeInfoForKafka struct {
	Sender      string  `json:"sender"`
	Stock       string  `json:"stock"`
	Money       string  `json:"money"`
	Amount      int64   `json:"amount"`
	Side        byte    `json:"side"`
	MoneyLimit  int64   `json:"money_limit"`
	TxPrice     sdk.Dec `json:"transaction_price"`
	BlockHeight int64   `json:"block_height"`

	TxHash string `json:"tx_hash,omitempty"`

	UsedCommission    int64  `json:"used_commission,omitempty"`
	RebateAmount      int64  `json:"rebate_amount,omitempty"`
	RebateRefereeAddr string `json:"rebate_referee_addr,omitempty"`
}

some users trade with bancor

type MsgToPush added in v0.0.19

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

A message to be sent to websocket subscriber through hub.msgsChannel

type NewHeightInfo

type NewHeightInfo struct {
	ChainID       string       `json:"chain_id,omitempty"`
	Height        int64        `json:"height"`
	TimeStamp     int64        `json:"timestamp"`
	LastBlockHash cmn.HexBytes `json:"last_block_hash"`
}

--------------------- common info timestamp field changes from string to int64

type NotificationBeginRedelegation

type NotificationBeginRedelegation struct {
	Delegator      string `json:"delegator"`
	ValidatorSrc   string `json:"src"`
	ValidatorDst   string `json:"dst"`
	Amount         string `json:"amount"`
	CompletionTime int64  `json:"completion_time"`

	TxHash string `json:"tx_hash,omitempty"`
}

------------------------ manager info someone is going to delegate a validator to stake or, someone who voted a validator before, but now he/she wants to delegate another validator

type NotificationBeginUnbonding

type NotificationBeginUnbonding struct {
	Delegator      string `json:"delegator"`
	Validator      string `json:"validator"`
	Amount         string `json:"amount"`
	CompletionTime int64  `json:"completion_time"`

	TxHash string `json:"tx_hash,omitempty"`
}

a validator leaves top 42 or a jailed validator becomes unjailed

type NotificationCompleteRedelegation

type NotificationCompleteRedelegation struct {
	Delegator    string `json:"delegator"`
	ValidatorSrc string `json:"src"`
	ValidatorDst string `json:"dst"`
}

the begin redelegation process is completed

type NotificationCompleteUnbonding

type NotificationCompleteUnbonding struct {
	Delegator string `json:"delegator"`
	Validator string `json:"validator"`
}

the unbounding process is completed

type NotificationDelegatorRewards added in v0.2.6

type NotificationDelegatorRewards struct {
	Validator string `json:"validator"`
	Rewards   string `json:"rewards"`
}

type NotificationSlash

type NotificationSlash struct {
	Validator string `json:"validator"`
	Power     string `json:"power"`
	Reason    string `json:"reason"`
	Jailed    bool   `json:"jailed"`
}

if validators do some illegal acts,they will be punished (e.g. losing votes) or even jailed

type NotificationTx

type NotificationTx struct {
	Signers      []string         `json:"signers"`
	Transfers    []TransferRecord `json:"transfers"`
	SerialNumber int64            `json:"serial_number"`
	MsgTypes     []string         `json:"msg_types"`
	TxJSON       string           `json:"tx_json"`
	Height       int64            `json:"height"`
	Hash         string           `json:"hash"`
	ExtraInfo    string           `json:"extra_info,omitempty"`
}

transaction

type NotificationUnlock

type NotificationUnlock struct {
	Address     string      `json:"address" yaml:"address"`
	Unlocked    sdk.Coins   `json:"unlocked"`
	LockedCoins LockedCoins `json:"locked_coins"`
	FrozenCoins sdk.Coins   `json:"frozen_coins"`
	Coins       sdk.Coins   `json:"coins" yaml:"coins"`
	Height      int64       `json:"height"`
}

unclock the locked coins

type NotificationValidatorCommission added in v0.2.6

type NotificationValidatorCommission struct {
	Validator  string `json:"validator"`
	Commission string `json:"commission"`
}

------------- block reward info

type OldBancorInfoForKafka added in v0.2.6

type OldBancorInfoForKafka struct {
	Owner              string `json:"sender"`
	Stock              string `json:"stock"`
	Money              string `json:"money"`
	InitPrice          string `json:"init_price"`
	MaxSupply          string `json:"max_supply"`
	StockPrecision     byte   `json:"stock_precision"`
	MaxPrice           string `json:"max_price"`
	Price              string `json:"price"`
	StockInPool        string `json:"stock_in_pool"`
	MoneyInPool        string `json:"money_in_pool"`
	EarliestCancelTime int64  `json:"earliest_cancel_time"`
}

type OldHeightInfo added in v0.2.6

type OldHeightInfo struct {
	ChainID       string       `json:"chain_id,omitempty"`
	Height        int64        `json:"height"`
	TimeStamp     string       `json:"timestamp"`
	LastBlockHash cmn.HexBytes `json:"last_block_hash"`
}

type OldNotificationBeginRedelegation added in v0.2.6

type OldNotificationBeginRedelegation struct {
	Delegator      string `json:"delegator"`
	ValidatorSrc   string `json:"src"`
	ValidatorDst   string `json:"dst"`
	Amount         string `json:"amount"`
	CompletionTime string `json:"completion_time"`
}

type OldNotificationBeginUnbonding added in v0.2.6

type OldNotificationBeginUnbonding struct {
	Delegator      string `json:"delegator"`
	Validator      string `json:"validator"`
	Amount         string `json:"amount"`
	CompletionTime string `json:"completion_time"`
}

type OrderInfo

type OrderInfo struct {
	CreateOrderInfo OrderResponse `json:"create_order_info"`
	FillOrderInfo   OrderResponse `json:"fill_order_info"`
	CancelOrderInfo OrderResponse `json:"cancel_order_info"`
}

type OrderResponse

type OrderResponse struct {
	Data    []json.RawMessage `json:"data"`
	Timesid []int64           `json:"timesid"`
}

type PlainSubscriber

type PlainSubscriber struct {
	ID int64
}

func (*PlainSubscriber) Detail

func (s *PlainSubscriber) Detail() interface{}

func (*PlainSubscriber) GetConn added in v0.0.2

func (s *PlainSubscriber) GetConn() *Conn

func (*PlainSubscriber) WriteMsg

func (s *PlainSubscriber) WriteMsg([]byte) error

type PricePoint

type PricePoint struct {
	Price  sdk.Dec `json:"p"`
	Amount sdk.Int `json:"a"`
}

type Pruneable added in v0.2.0

type Pruneable interface {
	SetPruneTimestamp(t uint64)
	GetPruneTimestamp() uint64
}

type Querier

type Querier interface {
	// All these functions can be safely called in goroutines.
	QueryTickers(marketList []string) []*Ticker
	QueryBlockTime(height int64, count int) []int64
	QueryDepth(market string, count int) (sell []*PricePoint, buy []*PricePoint)
	QueryCandleStick(market string, timespan byte, time int64, sid int64, count int) []json.RawMessage

	QueryLocked(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryDeal(market string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryBancorDeal(market string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryBancorInfo(market string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryBancorTrade(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryRedelegation(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryUnbonding(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryUnlock(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryIncome(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryTx(account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryComment(token string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QuerySlash(time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryDonation(time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryDelist(market string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

	QueryOrderAboutToken(tag, token, account string, time int64, sid int64, count int) (data []json.RawMessage, tags []byte, timesid []int64)
	QueryLockedAboutToken(token, account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryBancorTradeAboutToken(token, account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryUnlockAboutToken(token, account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryIncomeAboutToken(token, account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)
	QueryTxAboutToken(token, account string, time int64, sid int64, count int) (data []json.RawMessage, timesid []int64)

	QueryTxByHashID(hexHashID string) json.RawMessage
}

type SubscribeManager

type SubscribeManager interface {
	GetSlashSubscribeInfo() []Subscriber
	GetHeightSubscribeInfo() []Subscriber

	//The returned subscribers have detailed information of markets
	//one subscriber can subscribe tickers from no more than 100 markets
	GetTickerSubscribeInfo() []Subscriber

	//The returned subscribers have detailed information of timespan
	GetCandleStickSubscribeInfo() map[string][]Subscriber

	//the map keys are markets' names
	GetDepthSubscribeInfo() map[string][]Subscriber
	GetDealSubscribeInfo() map[string][]Subscriber

	//the map keys are bancor contracts' names
	GetBancorInfoSubscribeInfo() map[string][]Subscriber

	//the map keys are tokens' names
	GetCommentSubscribeInfo() map[string][]Subscriber

	//the map keys are accounts' bech32 addresses
	GetMarketSubscribeInfo() map[string][]Subscriber
	GetOrderSubscribeInfo() map[string][]Subscriber
	GetBancorTradeSubscribeInfo() map[string][]Subscriber
	GetBancorDealSubscribeInfo() map[string][]Subscriber
	GetIncomeSubscribeInfo() map[string][]Subscriber
	GetUnbondingSubscribeInfo() map[string][]Subscriber
	GetRedelegationSubscribeInfo() map[string][]Subscriber
	GetUnlockSubscribeInfo() map[string][]Subscriber
	GetTxSubscribeInfo() map[string][]Subscriber
	GetLockedSubscribeInfo() map[string][]Subscriber
	GetValidatorCommissionInfo() map[string][]Subscriber
	GetDelegationRewards() map[string][]Subscriber

	PushLockedSendMsg(subscriber Subscriber, info []byte)
	PushSlash(subscriber Subscriber, info []byte)
	PushHeight(subscriber Subscriber, info []byte)
	PushTicker(subscriber Subscriber, t []*Ticker)
	PushDepthFullMsg(subscriber Subscriber, info []byte)
	PushDepthWithChange(subscriber Subscriber, info []byte)
	PushDepthWithDelta(subscriber Subscriber, delta []byte)
	PushCandleStick(subscriber Subscriber, info []byte)
	PushDeal(subscriber Subscriber, info []byte)
	PushBancorDeal(subscriber Subscriber, info []byte)
	PushCreateMarket(subscriber Subscriber, info []byte)
	PushCreateOrder(subscriber Subscriber, info []byte)
	PushFillOrder(subscriber Subscriber, info []byte)
	PushCancelOrder(subscriber Subscriber, info []byte)
	PushBancorInfo(subscriber Subscriber, info []byte)
	PushBancorTrade(subscriber Subscriber, info []byte)
	PushIncome(subscriber Subscriber, info []byte)
	PushUnbonding(subscriber Subscriber, info []byte)
	PushRedelegation(subscriber Subscriber, info []byte)
	PushUnlock(subscriber Subscriber, info []byte)
	PushTx(subscriber Subscriber, info []byte)
	PushComment(subscriber Subscriber, info []byte)
	PushValidatorCommissionInfo(subscriber Subscriber, info []byte)
	PushDelegationRewards(subscriber Subscriber, info []byte)

	SetSkipOption(isSkip bool)
}

type Subscriber

type Subscriber interface {
	Detail() interface{}
	WriteMsg([]byte) error
	GetConn() *Conn
}

type Ticker

type Ticker struct {
	Market            string  `json:"market"`
	NewPrice          sdk.Dec `json:"new"`
	OldPriceOneDayAgo sdk.Dec `json:"old"`
	MinuteInDay       int     `json:"minute_in_day"`
}

type TickerManager

type TickerManager struct {
	// The prices in last 24 hours
	PriceList [MinuteNumInDay]sdk.Dec `json:"price_list"`
	// The following 4 members act like a small fifo
	// new Price goes first into Price1st, then goes into Price2nd,
	// finally Price2nd goes into PriceList
	Price1st  sdk.Dec `json:"price_1st"`
	Minute1st int     `json:"minute_1st"`
	Price2nd  sdk.Dec `json:"price_2nd"`
	Minute2nd int     `json:"minute_2nd"`

	Market      string `json:"market"`
	Initialized bool   `json:"initialized"`
}

func NewTickerManager added in v0.2.0

func NewTickerManager(Market string) *TickerManager

func (*TickerManager) GetTicker

func (tm *TickerManager) GetTicker(currMinute int) *Ticker

Return a Ticker if NewPrice or OldPriceOneDayAgo is different from its previous minute

func (*TickerManager) UpdateNewestPrice

func (tm *TickerManager) UpdateNewestPrice(currPrice sdk.Dec, currMinute int)

Flush the cached NewestPrice and NewestMinute to PriceList, and assign currPrice to NewestPrice, currMinute to NewestMinute

type TickerSubscriber

type TickerSubscriber struct {
	PlainSubscriber
	Markets map[string]struct{}
}

func NewTickerSubscriber

func NewTickerSubscriber(id int64, markets map[string]struct{}) *TickerSubscriber

func (*TickerSubscriber) Detail

func (s *TickerSubscriber) Detail() interface{}

func (*TickerSubscriber) GetConn added in v0.0.2

func (s *TickerSubscriber) GetConn() *Conn

func (*TickerSubscriber) WriteMsg

func (s *TickerSubscriber) WriteMsg([]byte) error

type TimeAndSidWithAddr added in v0.0.19

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

type TokenComment

type TokenComment struct {
	ID          uint64       `json:"id"`
	Height      int64        `json:"height"`
	Sender      string       `json:"sender"`
	Token       string       `json:"token"`
	Donation    int64        `json:"donation"`
	Title       string       `json:"title"`
	Content     string       `json:"content"`
	ContentType int8         `json:"content_type"`
	References  []CommentRef `json:"references"`

	TxHash string `json:"tx_hash,omitempty"`
}

type TransferRecord

type TransferRecord struct {
	Sender    string `json:"sender"`
	Recipient string `json:"recipient"`
	Amount    string `json:"amount"`
}

type TripleManager

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

Each market needs three managers

func (*TripleManager) AddDeltaChange added in v0.2.0

func (triman *TripleManager) AddDeltaChange(isSell bool, price sdk.Dec, amount sdk.Int)

func (*TripleManager) Update added in v0.2.0

func (triman *TripleManager) Update(lockCount *int64)

type WebsocketManager

type WebsocketManager struct {
	SkipPushed bool // skip the messages to be pushed to subscribers, used during startup
	// contains filtered or unexported fields
}

func NewWebSocketManager

func NewWebSocketManager() *WebsocketManager

func (*WebsocketManager) AddSubscribeConn

func (w *WebsocketManager) AddSubscribeConn(c *Conn, topic string, params []string) error

func (*WebsocketManager) AddWsConn added in v0.0.19

func (w *WebsocketManager) AddWsConn(c WsInterface) *Conn

Wrap this WsInterface with 'Conn' and return this 'Conn' The map 'wsConn2Conn' ensures for the same WsInterface, we only wrap it once

func (*WebsocketManager) CloseWsConn added in v0.2.0

func (w *WebsocketManager) CloseWsConn(c *Conn)

func (*WebsocketManager) GetBancorDealSubscribeInfo added in v0.0.19

func (w *WebsocketManager) GetBancorDealSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetBancorInfoSubscribeInfo

func (w *WebsocketManager) GetBancorInfoSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetBancorTradeSubscribeInfo

func (w *WebsocketManager) GetBancorTradeSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetCandleStickSubscribeInfo

func (w *WebsocketManager) GetCandleStickSubscribeInfo() map[string][]Subscriber

The key of the result map is market

func (*WebsocketManager) GetCommentSubscribeInfo

func (w *WebsocketManager) GetCommentSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetDealSubscribeInfo

func (w *WebsocketManager) GetDealSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetDelegationRewards added in v0.2.6

func (w *WebsocketManager) GetDelegationRewards() map[string][]Subscriber

func (*WebsocketManager) GetDepthSubscribeInfo

func (w *WebsocketManager) GetDepthSubscribeInfo() map[string][]Subscriber

The key of the result map is market

func (*WebsocketManager) GetHeightSubscribeInfo

func (w *WebsocketManager) GetHeightSubscribeInfo() []Subscriber

func (*WebsocketManager) GetIncomeSubscribeInfo

func (w *WebsocketManager) GetIncomeSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetLockedSubscribeInfo

func (w *WebsocketManager) GetLockedSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetMarketSubscribeInfo added in v0.2.6

func (w *WebsocketManager) GetMarketSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetOrderSubscribeInfo

func (w *WebsocketManager) GetOrderSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetRedelegationSubscribeInfo

func (w *WebsocketManager) GetRedelegationSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetSlashSubscribeInfo

func (w *WebsocketManager) GetSlashSubscribeInfo() []Subscriber

func (*WebsocketManager) GetTickerSubscribeInfo

func (w *WebsocketManager) GetTickerSubscribeInfo() []Subscriber

func (*WebsocketManager) GetTxSubscribeInfo

func (w *WebsocketManager) GetTxSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetUnbondingSubscribeInfo

func (w *WebsocketManager) GetUnbondingSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetUnlockSubscribeInfo

func (w *WebsocketManager) GetUnlockSubscribeInfo() map[string][]Subscriber

func (*WebsocketManager) GetValidatorCommissionInfo added in v0.2.6

func (w *WebsocketManager) GetValidatorCommissionInfo() map[string][]Subscriber

func (*WebsocketManager) PushBancorDeal added in v0.0.19

func (w *WebsocketManager) PushBancorDeal(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushBancorInfo

func (w *WebsocketManager) PushBancorInfo(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushBancorTrade

func (w *WebsocketManager) PushBancorTrade(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushCancelOrder

func (w *WebsocketManager) PushCancelOrder(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushCandleStick

func (w *WebsocketManager) PushCandleStick(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushComment

func (w *WebsocketManager) PushComment(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushCreateMarket added in v0.2.6

func (w *WebsocketManager) PushCreateMarket(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushCreateOrder

func (w *WebsocketManager) PushCreateOrder(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushDeal

func (w *WebsocketManager) PushDeal(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushDelegationRewards added in v0.2.6

func (w *WebsocketManager) PushDelegationRewards(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushDepthFullMsg added in v0.2.0

func (w *WebsocketManager) PushDepthFullMsg(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushDepthWithChange added in v0.0.2

func (w *WebsocketManager) PushDepthWithChange(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushDepthWithDelta added in v0.0.2

func (w *WebsocketManager) PushDepthWithDelta(subscriber Subscriber, delta []byte)

func (*WebsocketManager) PushFillOrder

func (w *WebsocketManager) PushFillOrder(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushFullInfo added in v0.2.0

func (w *WebsocketManager) PushFullInfo(hub *Hub, c *Conn, topic string, params []string, count int) error

func (*WebsocketManager) PushHeight

func (w *WebsocketManager) PushHeight(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushIncome

func (w *WebsocketManager) PushIncome(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushLockedSendMsg

func (w *WebsocketManager) PushLockedSendMsg(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushRedelegation

func (w *WebsocketManager) PushRedelegation(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushSlash

func (w *WebsocketManager) PushSlash(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushTicker

func (w *WebsocketManager) PushTicker(subscriber Subscriber, t []*Ticker)

func (*WebsocketManager) PushTx

func (w *WebsocketManager) PushTx(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushUnbonding

func (w *WebsocketManager) PushUnbonding(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushUnlock

func (w *WebsocketManager) PushUnlock(subscriber Subscriber, info []byte)

func (*WebsocketManager) PushValidatorCommissionInfo added in v0.2.6

func (w *WebsocketManager) PushValidatorCommissionInfo(subscriber Subscriber, info []byte)

func (*WebsocketManager) RemoveSubscribeConn

func (w *WebsocketManager) RemoveSubscribeConn(c *Conn, topic string, params []string) error

func (*WebsocketManager) SetSkipOption

func (w *WebsocketManager) SetSkipOption(isSkip bool)

type WsInterface added in v0.2.0

type WsInterface interface {
	Close() error
	WriteMessage(msgType int, data []byte) error
	ReadMessage() (messageType int, p []byte, err error)
	SetPingHandler(func(string) error)
	PingHandler() func(string) error
}

type XTicker

type XTicker struct {
	Market            string  `json:"market"`
	NewPrice          sdk.Dec `json:"new"`
	OldPriceOneDayAgo sdk.Dec `json:"old"`
	MinuteInDay       int     `json:"minute_in_day"`
	HighPrice         sdk.Dec `json:"high"`
	LowPrice          sdk.Dec `json:"low"`
	TotalDeal         sdk.Int `json:"volume"`
}

type XTickerManager

type XTickerManager struct {
	PriceList         [MinuteNumInDay]sdk.Dec `json:"price_list"`
	AmountList        [MinuteNumInDay]sdk.Int `json:"amount_list"`
	Highest           sdk.Dec                 `json:"highest"`
	Lowest            sdk.Dec                 `json:"lowest"`
	Market            string                  `json:"market"`
	Initialized       bool                    `json:"initialized"`
	TotalAmount       sdk.Int                 `json:"amount"`
	LastUpdate        int                     `json:"amount_last_update"`
	OldPriceOneDayAgo sdk.Dec                 `json:"old_price"`
}

func NewXTickerManager added in v0.2.0

func NewXTickerManager(Market string) *XTickerManager

func (*XTickerManager) GetXTicker

func (tm *XTickerManager) GetXTicker(currMinute int) *XTicker

func (*XTickerManager) UpdateNewestPrice

func (tm *XTickerManager) UpdateNewestPrice(currPrice sdk.Dec, currMinute int, currAmount sdk.Int)

Jump to

Keyboard shortcuts

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