Documentation ¶
Index ¶
- Constants
- func AddAccount(ma *MgoAccount) error
- func AddBlock(mb *MgoBlock, overwrite bool) (err error)
- func AddDistributeInfo(ma *MgoDistributeInfo) error
- func AddLiquidRewardResult(mr *MgoLiquidRewardResult) (err error)
- func AddLiquidity(ml *MgoLiquidity, overwrite bool) (err error)
- func AddLiquidityBalance(ma *MgoLiquidityBalance) error
- func AddTokenAccount(ma *MgoTokenAccount) error
- func AddTransaction(mt *MgoTransaction, overwrite bool) error
- func AddVolume(mv *MgoVolume, overwrite bool) (err error)
- func AddVolumeHistory(mv *MgoVolumeHistory, overwrite bool) (err error)
- func AddVolumeRewardResult(mr *MgoVolumeRewardResult) (err error)
- func CalcRewardsInBatch(stats []AccountStatSlice, rewards []*big.Int)
- func CalcWeightedRewards(stats []AccountStatSlice, totalReward *big.Int, weights []uint64)
- func DivideRewards(totalReward *big.Int, totalShareSlice []*big.Int) (rewards []*big.Int)
- func FindAllAccounts(exchange string) (accounts []common.Address)
- func FindAllTokenAccounts(token string) (accounts []common.Address)
- func FindLiquidityBalance(exchange, account string, blockNumber uint64) (string, error)
- func GetKeyOfExchangeAndAccount(exchange, account string) string
- func GetKeyOfExchangeAndTimestamp(exchange string, timestamp uint64) string
- func GetKeyOfLiquidityBalance(exchange, account string, blockNumber uint64) string
- func GetKeyOfRewardResult(exchange, account string, start uint64) string
- func GetKeyOfTokenAndAccount(token, account string) string
- func GetKeyOfVolumeHistory(txhash string, logIndex int) string
- func MongoServerInit(addrs []string, dbname, user, pass string)
- func TryDoTimes(name string, f func() error) (err error)
- func UpdateSyncInfo(number uint64, hash string, timestamp uint64) error
- func UpdateVolumeWithReceipt(exr *ExchangeReceipt, blockHash string, blockNumber, timestamp uint64) error
- type AccountStat
- type AccountStatSlice
- func (s AccountStatSlice) CalcRewards(totalReward *big.Int)
- func (s AccountStatSlice) CalcTotalReward() *big.Int
- func (s AccountStatSlice) CalcTotalShare() *big.Int
- func (s AccountStatSlice) IsAccountExist(account common.Address) bool
- func (s AccountStatSlice) Len() int
- func (s AccountStatSlice) Less(i, j int) bool
- func (s AccountStatSlice) SumWeightShares(weight uint64) (totalWeightShare *big.Int)
- func (s AccountStatSlice) Swap(i, j int)
- type Erc20Receipt
- type ExchangeReceipt
- type MgoAccount
- type MgoBlock
- type MgoDistributeInfo
- type MgoLiquidRewardResult
- type MgoLiquidity
- type MgoLiquidityBalance
- type MgoSyncInfo
- type MgoTokenAccount
- type MgoTransaction
- type MgoVolume
- type MgoVolumeHistory
- type MgoVolumeRewardResult
Constants ¶
const ( // KeyOfLatestSyncInfo key KeyOfLatestSyncInfo string = "latest" )
Variables ¶
This section is empty.
Functions ¶
func AddDistributeInfo ¶
func AddDistributeInfo(ma *MgoDistributeInfo) error
AddDistributeInfo add distributeInfo
func AddLiquidRewardResult ¶
func AddLiquidRewardResult(mr *MgoLiquidRewardResult) (err error)
AddLiquidRewardResult add volume reward result
func AddLiquidity ¶
func AddLiquidity(ml *MgoLiquidity, overwrite bool) (err error)
AddLiquidity add liquidity
func AddLiquidityBalance ¶
func AddLiquidityBalance(ma *MgoLiquidityBalance) error
AddLiquidityBalance add liquidity balance
func AddTokenAccount ¶
func AddTokenAccount(ma *MgoTokenAccount) error
AddTokenAccount add token account
func AddTransaction ¶
func AddTransaction(mt *MgoTransaction, overwrite bool) error
AddTransaction add tx
func AddVolumeHistory ¶
func AddVolumeHistory(mv *MgoVolumeHistory, overwrite bool) (err error)
AddVolumeHistory add volume history
func AddVolumeRewardResult ¶
func AddVolumeRewardResult(mr *MgoVolumeRewardResult) (err error)
AddVolumeRewardResult add volume reward result
func CalcRewardsInBatch ¶ added in v0.1.4
func CalcRewardsInBatch(stats []AccountStatSlice, rewards []*big.Int)
CalcRewardsInBatch calc rewards in batch
func CalcWeightedRewards ¶
func CalcWeightedRewards(stats []AccountStatSlice, totalReward *big.Int, weights []uint64)
CalcWeightedRewards calc weighted rewards
func DivideRewards ¶
DivideRewards divide rewards
func FindAllAccounts ¶
FindAllAccounts find accounts
func FindAllTokenAccounts ¶
FindAllTokenAccounts find accounts
func FindLiquidityBalance ¶
FindLiquidityBalance find liquidity balance
func GetKeyOfExchangeAndAccount ¶
GetKeyOfExchangeAndAccount get key
func GetKeyOfExchangeAndTimestamp ¶
GetKeyOfExchangeAndTimestamp get key
func GetKeyOfLiquidityBalance ¶
GetKeyOfLiquidityBalance get key
func GetKeyOfRewardResult ¶
GetKeyOfRewardResult get key
func GetKeyOfTokenAndAccount ¶
GetKeyOfTokenAndAccount get key
func GetKeyOfVolumeHistory ¶
GetKeyOfVolumeHistory get key
func MongoServerInit ¶
MongoServerInit int mongodb server session
func TryDoTimes ¶
TryDoTimes try do again if meet error
func UpdateSyncInfo ¶
UpdateSyncInfo update sync info
func UpdateVolumeWithReceipt ¶
func UpdateVolumeWithReceipt(exr *ExchangeReceipt, blockHash string, blockNumber, timestamp uint64) error
UpdateVolumeWithReceipt update volume
Types ¶
type AccountStat ¶
type AccountStat struct { Account common.Address Reward *big.Int Number uint64 // txcount or height }
AccountStat account statistics
func (*AccountStat) String ¶
func (s *AccountStat) String() string
type AccountStatSlice ¶
type AccountStatSlice []*AccountStat
AccountStatSlice slice sort by reward in reverse order
func ConvertToSortedSlice ¶
func ConvertToSortedSlice(statMap map[common.Address]*AccountStat) AccountStatSlice
ConvertToSortedSlice convert to sorted slice
func FindAccountVolumes ¶
func FindAccountVolumes(exchange string, startHeight, endHeight uint64, useTimestamp bool) AccountStatSlice
FindAccountVolumes find account volumes
func (AccountStatSlice) CalcRewards ¶
func (s AccountStatSlice) CalcRewards(totalReward *big.Int)
CalcRewards calc rewards by shares
func (AccountStatSlice) CalcTotalReward ¶
func (s AccountStatSlice) CalcTotalReward() *big.Int
CalcTotalReward calc the summary
func (AccountStatSlice) CalcTotalShare ¶
func (s AccountStatSlice) CalcTotalShare() *big.Int
CalcTotalShare calc the summary
func (AccountStatSlice) IsAccountExist ¶
func (s AccountStatSlice) IsAccountExist(account common.Address) bool
IsAccountExist is account exist in slice
func (AccountStatSlice) Len ¶
func (s AccountStatSlice) Len() int
func (AccountStatSlice) Less ¶
func (s AccountStatSlice) Less(i, j int) bool
func (AccountStatSlice) SumWeightShares ¶
func (s AccountStatSlice) SumWeightShares(weight uint64) (totalWeightShare *big.Int)
SumWeightShares sum weight shares (do not change slice itself)
func (AccountStatSlice) Swap ¶
func (s AccountStatSlice) Swap(i, j int)
type Erc20Receipt ¶
type Erc20Receipt struct { LogType string `bson:"logType"` LogIndex int `bson:"logIndex"` Erc20 string `bson:"erc20"` From string `bson:"from"` To string `bson:"to"` Value string `bson:"value"` }
Erc20Receipt erc20 tx receipt
type ExchangeReceipt ¶
type ExchangeReceipt struct { LogType string `bson:"txnsType"` LogIndex int `bson:"logIndex"` Exchange string `bson:"exchange"` Pairs string `bson:"pairs"` Address string `bson:"address"` TokenFromAmount string `bson:"tokenFromAmount"` TokenToAmount string `bson:"tokenToAmount"` }
ExchangeReceipt exchange tx receipt
type MgoAccount ¶
type MgoAccount struct { Key string `bson:"_id"` // exchange + account Exchange string `bson:"exchange"` Pairs string `bson:"pairs"` Account string `bson:"account"` }
MgoAccount exchange account
type MgoBlock ¶
type MgoBlock struct { Key string `bson:"_id"` // = hash Number uint64 `bson:"number"` Hash string `bson:"hash"` ParentHash string `bson:"parentHash"` Nonce string `bson:"nonce"` Miner string `bson:"miner"` Difficulty string `bson:"difficulty"` GasLimit uint64 `bson:"gasLimit"` GasUsed uint64 `bson:"gasUsed"` Timestamp uint64 `bson:"timestamp"` }
MgoBlock block
func FindBlocksInRange ¶
FindBlocksInRange find blocks
type MgoDistributeInfo ¶
type MgoDistributeInfo struct { Key bson.ObjectId `bson:"_id"` Exchange string `bson:"exchange"` Pairs string `bson:"pairs"` ByWhat string `bson:"bywhat"` Start uint64 `bson:"start"` End uint64 `bson:"end"` RewardToken string `bson:"rewardToken"` Rewards string `bson:"rewards"` SampleHeight uint64 `bson:"sampleHeight,omitempty"` Timestamp uint64 `bson:"timestamp"` }
MgoDistributeInfo distribute info
type MgoLiquidRewardResult ¶
type MgoLiquidRewardResult struct { Key string `bson:"_id"` // exchange + account + start Exchange string `bson:"exchange"` Pairs string `bson:"pairs"` Start uint64 `bson:"start"` End uint64 `bson:"end"` RewardToken string `bson:"rewardToken"` Account string `bson:"account"` Reward string `bson:"reward"` Liquidity string `bson:"liquidity"` Height uint64 `bson:"height"` RewardTx string `bson:"rewardTx"` Timestamp uint64 `bson:"timestamp"` }
MgoLiquidRewardResult liquidity reward
func FindLiquidRewardResult ¶
func FindLiquidRewardResult(key string) (*MgoLiquidRewardResult, error)
FindLiquidRewardResult find liquid reward result
type MgoLiquidity ¶
type MgoLiquidity struct { Key string `bson:"_id"` // exchange + timestamp Exchange string `bson:"exchange"` Pairs string `bson:"pairs"` Coin string `bson:"coin"` Token string `bson:"token"` Liquidity string `bson:"liquidity"` BlockNumber uint64 `bson:"blockNumber"` BlockHash string `bson:"blockHash"` Timestamp uint64 `bson:"timestamp"` }
MgoLiquidity liquidity
func FindLatestLiquidity ¶
func FindLatestLiquidity(exchange string) (*MgoLiquidity, error)
FindLatestLiquidity find latest liquidity
func FindLiquidity ¶
func FindLiquidity(key string) (*MgoLiquidity, error)
FindLiquidity find by key
type MgoLiquidityBalance ¶
type MgoLiquidityBalance struct { Key string `bson:"_id"` // exchange + account + blockNumber Exchange string `bson:"exchange"` Pairs string `bson:"pairs"` Account string `bson:"account"` BlockNumber uint64 `bson:"blockNumber"` Liquidity string `bson:"liquidity"` }
MgoLiquidityBalance liquidity balance
type MgoSyncInfo ¶
type MgoSyncInfo struct { Key string `bson:"_id"` Number uint64 `bson:"number"` Hash string `bson:"hash"` Timestamp uint64 `bson:"timestamp"` }
MgoSyncInfo sync info
func FindLatestSyncInfo ¶
func FindLatestSyncInfo() (*MgoSyncInfo, error)
FindLatestSyncInfo find latest sync info
type MgoTokenAccount ¶
type MgoTokenAccount struct { Key string `bson:"_id"` // token + account Token string `bson:"token"` Account string `bson:"account"` }
MgoTokenAccount token account
type MgoTransaction ¶
type MgoTransaction struct { Key string `bson:"_id"` // = hash Hash string `bson:"hash"` BlockNumber uint64 `bson:"blockNumber"` BlockHash string `bson:"blockHash"` TransactionIndex int `bson:"transactionIndex"` From string `bson:"from"` To string `bson:"to"` Value string `bson:"value"` Nonce uint64 `bson:"nonce"` GasLimit uint64 `bson:"gasLimit"` GasUsed uint64 `bson:"gasUsed"` GasPrice string `bson:"gasPrice"` Status uint64 `bson:"status"` Timestamp uint64 `bson:"timestamp"` Erc20Receipts []*Erc20Receipt `bson:"erc20Receipts,omitempty"` ExchangeReceipts []*ExchangeReceipt `bson:"exchangeReceipts,omitempty"` }
MgoTransaction tx
type MgoVolume ¶
type MgoVolume struct { Key string `bson:"_id"` // exchange + timestamp Exchange string `bson:"exchange"` Pairs string `bson:"pairs"` CoinVolume24h string `bson:"cvolume24h"` TokenVolume24h string `bson:"tvolume24h"` BlockNumber uint64 `bson:"blockNumber"` BlockHash string `bson:"blockHash"` Timestamp uint64 `bson:"timestamp"` }
MgoVolume volumn
func FindLatestVolume ¶
FindLatestVolume find latest volume
type MgoVolumeHistory ¶
type MgoVolumeHistory struct { Key string `bson:"_id"` // txhash + logIndex Exchange string `bson:"exchange"` Pairs string `bson:"pairs"` Account string `bson:"account"` CoinAmount string `bson:"coinAmount"` TokenAmount string `bson:"tokenAmount"` BlockNumber uint64 `bson:"blockNumber"` Timestamp uint64 `bson:"timestamp"` TxHash string `bson:"txhash"` LogType string `bson:"logType"` LogIndex int `bson:"logIndex"` }
MgoVolumeHistory volmue tx history
type MgoVolumeRewardResult ¶
type MgoVolumeRewardResult struct { Key string `bson:"_id"` // exchange + account + start Exchange string `bson:"exchange"` Pairs string `bson:"pairs"` Start uint64 `bson:"start"` End uint64 `bson:"end"` RewardToken string `bson:"rewardToken"` Account string `bson:"account"` Reward string `bson:"reward"` Volume string `bson:"volume"` TxCount uint64 `bson:"txcount"` RewardTx string `bson:"rewardTx"` Timestamp uint64 `bson:"timestamp"` }
MgoVolumeRewardResult volume reward
func FindVolumeRewardResult ¶
func FindVolumeRewardResult(key string) (*MgoVolumeRewardResult, error)
FindVolumeRewardResult find volume reward result