Documentation ¶
Index ¶
- type Client
- func (c *Client) AddAccount(account *DBAccount) error
- func (c *Client) AddBlock(b *DBBlock) error
- func (c *Client) AddDebtTxs(debttxs ...interface{}) error
- func (c *Client) AddLastBlocks(blocks ...interface{}) error
- func (c *Client) AddNodeInfo(nodeInfo *DBNodeInfo) error
- func (c *Client) AddOneDayAddress(shardNumber int, t *DBOneDayAddressInfo) error
- func (c *Client) AddOneDayBlock(shardNumber int, t *DBOneDayBlockInfo) error
- func (c *Client) AddOneDayBlockAvgTime(shardNumber int, t *DBOneDayBlockAvgTime) error
- func (c *Client) AddOneDayBlockDifficulty(shardNumber int, t *DBOneDayBlockDifficulty) error
- func (c *Client) AddOneDayHashRate(shardNumber int, t *DBOneDayHashRate) error
- func (c *Client) AddOneDaySingleAddressInfo(shardNumber int, t *DBOneDaySingleAddressInfo) error
- func (c *Client) AddOneDayTransInfo(shardNumber int, t *DBOneDayTxInfo) error
- func (c *Client) AddPendingTx(tx *DBTx) error
- func (c *Client) AddTopMinerInfo(shardNumber int, rankInfo *DBMinerRankInfo) error
- func (c *Client) AddTx(tx *DBTx) error
- func (c *Client) AddTxs(txs ...interface{}) error
- func (c *Client) DeleteNodeInfo(nodeInfo *DBNodeInfo) error
- func (c *Client) GetAccountByAddress(address string) (*DBAccount, error)
- func (c *Client) GetAccountCnt() (uint64, error)
- func (c *Client) GetAccountCntByShardNumber(shardNumber int) (uint64, error)
- func (c *Client) GetAccountsByHome() []*DBAccount
- func (c *Client) GetAccountsByShardNumber(shardNumber int, max int) ([]*DBAccount, error)
- func (c *Client) GetBlockByHash(hash string) (*DBBlock, error)
- func (c *Client) GetBlockByHeight(shardNumber int, height uint64) (*DBBlock, error)
- func (c *Client) GetBlockCnt() (uint64, error)
- func (c *Client) GetBlockHeight(shardNumber int) (uint64, error)
- func (c *Client) GetBlockProTime() (int64, int64, error)
- func (c *Client) GetBlockTxsTps() (float64, error)
- func (c *Client) GetBlockfee(block uint64) (int64, error)
- func (c *Client) GetBlocksByHeight(shardNumber int, begin uint64, end uint64) ([]*DBBlock, error)
- func (c *Client) GetBlocksByTime(shardNumber int, beginTime, endTime int64) ([]*DBBlock, error)
- func (c *Client) GetContractCnt() (uint64, error)
- func (c *Client) GetContractCntByShardNumber(shardNumber int) (uint64, error)
- func (c *Client) GetContractsByShardNumber(shardNumber int, max int) ([]*DBAccount, error)
- func (c *Client) GetDebtByHash(hash string) (*Debt, error)
- func (c *Client) GetHashRateChart() ([]*DBOneDayHashRate, error)
- func (c *Client) GetHashRateChartByShardNumber(shardNumber int) ([]*DBOneDayHashRate, error)
- func (c *Client) GetLastBlocksByShard(shard int) ([]*DBLastBlock, error)
- func (c *Client) GetMinedBlocksByShardNumberAndAddress(shardNumber int, address string) (int64, int64, int64, error)
- func (c *Client) GetMinedBlocksCntByShardNumberAndAddress(shardNumber int, address string) (int64, error)
- func (c *Client) GetMinerAccountByAddress(address string) (*DBMiner, error)
- func (c *Client) GetMinerAccounts(size int) ([]*DBMiner, error)
- func (c *Client) GetNodeCntByShardNumber(shardNumber int) (uint64, error)
- func (c *Client) GetNodeInfo(host string) (*DBNodeInfo, error)
- func (c *Client) GetNodeInfoByID(id string) (*DBNodeInfo, error)
- func (c *Client) GetNodeInfos() ([]*DBNodeInfo, error)
- func (c *Client) GetNodeInfosByShardNumber(shardNumber int) ([]*DBNodeInfo, error)
- func (c *Client) GetOneDayAddress(shardNumber int, zeroTime int64) (*DBOneDayAddressInfo, error)
- func (c *Client) GetOneDayAddressesChart() ([]*DBOneDayAddressInfo, error)
- func (c *Client) GetOneDayAddressesChartByShardNumber(shardNumber int) ([]*DBOneDayAddressInfo, error)
- func (c *Client) GetOneDayBlock(shardNumber int, zeroTime int64) (*DBOneDayBlockInfo, error)
- func (c *Client) GetOneDayBlockAvgTime(shardNumber int, zeroTime int64) (*DBOneDayBlockAvgTime, error)
- func (c *Client) GetOneDayBlockAvgTimeChart() ([]*DBOneDayBlockAvgTime, error)
- func (c *Client) GetOneDayBlockAvgTimeChartByShardNumber(shardNumber int) ([]*DBOneDayBlockAvgTime, error)
- func (c *Client) GetOneDayBlockDifficulty(shardNumber int, zeroTime int64) (*DBOneDayBlockDifficulty, error)
- func (c *Client) GetOneDayBlockDifficultyChart() ([]*DBOneDayBlockDifficulty, error)
- func (c *Client) GetOneDayBlockDifficultyChartByShardNumber(shardNumber int) ([]*DBOneDayBlockDifficulty, error)
- func (c *Client) GetOneDayBlocksChart() ([]*DBOneDayBlockInfo, error)
- func (c *Client) GetOneDayBlocksChartByShardNumber(shardNumber int) ([]*DBOneDayBlockInfo, error)
- func (c *Client) GetOneDayHashRate(shardNumber int, zeroTime int64) (*DBOneDayHashRate, error)
- func (c *Client) GetOneDaySingleAddressInfo(shardNumber int, address string) (*DBOneDaySingleAddressInfo, error)
- func (c *Client) GetOneDayTransInfo(shardNumber int, zeroTime int64) (*DBOneDayTxInfo, error)
- func (c *Client) GetPendingTxByHash(hash string) (*DBTx, error)
- func (c *Client) GetPendingTxCntByShardNumber(shardNumber int) (uint64, error)
- func (c *Client) GetPendingTxsByAddress(address string) ([]*DBTx, error)
- func (c *Client) GetPendingTxsByIdx(shardNumber int, begin uint64, end uint64) ([]*DBTx, error)
- func (c *Client) GetTopMinerChart() ([]*DBMinerRankInfo, error)
- func (c *Client) GetTopMinerChartByShardNumber(shardNumber int) ([]*DBMinerRankInfo, error)
- func (c *Client) GetTotalBalance() (map[int]int64, error)
- func (c *Client) GetTransInfoChart() ([]*DBOneDayTxInfo, error)
- func (c *Client) GetTransInfoChartByShardNumber(shardNumber int) ([]*DBOneDayTxInfo, error)
- func (c *Client) GetTxByHash(hash string) (*DBTx, error)
- func (c *Client) GetTxByIdx(idx uint64) (*DBTx, error)
- func (c *Client) GetTxCnt() (uint64, error)
- func (c *Client) GetTxCntAndAccTypeByAddressFromAccount(address string) (int64, int, error)
- func (c *Client) GetTxCntByAddressFromAccount(address string) (int64, error)
- func (c *Client) GetTxCntByShardNumber(shardNumber int) (uint64, error)
- func (c *Client) GetTxCntByShardNumberAndAddress(shardNumber int, address string) (int64, error)
- func (c *Client) GetTxHis(startDate, today string) ([]*DBSimpleTxs, error)
- func (c *Client) GetTxHisCntByDate(date string) (uint64, error)
- func (c *Client) GetTxs(shardNumber int, sort string, desc bool, limit int, skip int) ([]*DBTx, error)
- func (c *Client) GetTxsByAddresses(address string, asc bool, limit int, skip int) ([]*DBTx, error)
- func (c *Client) GetTxsByIdx(shardNumber int, begin uint64, end uint64) ([]*DBTx, error)
- func (c *Client) GetTxsDayCount() ([]*DBTx, error)
- func (c *Client) GetTxsinfoByDate(date string) (int64, int64, int64, int64, error)
- func (c *Client) GetblockdebtCntByShardNumber(shardNumber int, height uint64) (uint64, error)
- func (c *Client) GetblockdebtsByIdx(shardNumber int, height uint64, begin uint64, end uint64) ([]*Debt, error)
- func (c *Client) GetdebtCntByShardNumber(shardNumber int) (uint64, error)
- func (c *Client) GetdebtsByIdx(shardNumber int, begin uint64, end uint64) ([]*Debt, error)
- func (c *Client) InitTxCntByShardNumber(shardNumber int) error
- func (c *Client) LiveServers() []string
- func (c *Client) RemoveAllPendingTxs() error
- func (c *Client) RemoveBlock(shard int, height uint64) error
- func (c *Client) RemoveLastBlocksByShard(shard int) error
- func (c *Client) RemoveOutDateByDate(date string) error
- func (c *Client) RemoveTopMinerInfo() error
- func (c *Client) RemoveTxs(shard int, blockHeight uint64) error
- func (c *Client) SetPrimaryMode()
- func (c *Client) SetSecondaryPreferredMode()
- func (c *Client) UpdateAccount(account *DBAccount) error
- func (c *Client) UpdateAccountMinedBlock(address string, mined int64) error
- func (c *Client) UpdateBlock(shard int, height uint64, b *DBBlock) error
- func (c *Client) UpdateLastBlock(height int64, block *DBLastBlock) error
- func (c *Client) UpdateMinerAccount(miner *DBMiner) error
- func (c *Client) UpdateTxsCntByDate(tx *DBSimpleTxs) error
- type DBAccount
- type DBBlock
- type DBLastBlock
- type DBMiner
- type DBMinerRankInfo
- type DBNodeInfo
- type DBOneDayAddressInfo
- type DBOneDayBlockAvgTime
- type DBOneDayBlockDifficulty
- type DBOneDayBlockInfo
- type DBOneDayHashRate
- type DBOneDaySingleAddressInfo
- type DBOneDayTxInfo
- type DBSimpleDebtInBlock
- type DBSimpleTxInBlock
- type DBSimpleTxs
- type DBSingleMinerRankInfo
- type DBTx
- type Debt
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client warpper for mongodb interactive
func NewDBClient ¶
func NewDBClient(cfg *common.DataBaseConfig, shardNumber int) *Client
NewDBClient reuturn an DB client
func (*Client) AddAccount ¶
AddAccount insert an account into database
func (*Client) AddDebtTxs ¶
AddDebtTxs insert a transaction into mongo
func (*Client) AddLastBlocks ¶
AddLastBlocks insert last two blocks into database
func (*Client) AddNodeInfo ¶
func (c *Client) AddNodeInfo(nodeInfo *DBNodeInfo) error
AddNodeInfo add node info into database
func (*Client) AddOneDayAddress ¶
func (c *Client) AddOneDayAddress(shardNumber int, t *DBOneDayAddressInfo) error
AddOneDayAddress insert one dya block info into mongo
func (*Client) AddOneDayBlock ¶
func (c *Client) AddOneDayBlock(shardNumber int, t *DBOneDayBlockInfo) error
AddOneDayBlock insert one dya block info into mongo
func (*Client) AddOneDayBlockAvgTime ¶
func (c *Client) AddOneDayBlockAvgTime(shardNumber int, t *DBOneDayBlockAvgTime) error
AddOneDayBlockAvgTime insert one dya avg block time info into mongo
func (*Client) AddOneDayBlockDifficulty ¶
func (c *Client) AddOneDayBlockDifficulty(shardNumber int, t *DBOneDayBlockDifficulty) error
AddOneDayBlockDifficulty insert one dya avg block difficulty info into mongo
func (*Client) AddOneDayHashRate ¶
func (c *Client) AddOneDayHashRate(shardNumber int, t *DBOneDayHashRate) error
AddOneDayHashRate insert one dya hashrate info into mongo
func (*Client) AddOneDaySingleAddressInfo ¶
func (c *Client) AddOneDaySingleAddressInfo(shardNumber int, t *DBOneDaySingleAddressInfo) error
AddOneDaySingleAddressInfo insert one dya single address info into mongo
func (*Client) AddOneDayTransInfo ¶
func (c *Client) AddOneDayTransInfo(shardNumber int, t *DBOneDayTxInfo) error
AddOneDayTransInfo insert one dya transaction info into mongo
func (*Client) AddPendingTx ¶
AddPendingTx insert a pending transaction into mongo
func (*Client) AddTopMinerInfo ¶
func (c *Client) AddTopMinerInfo(shardNumber int, rankInfo *DBMinerRankInfo) error
AddTopMinerInfo add top miner rank info into database
func (*Client) DeleteNodeInfo ¶
func (c *Client) DeleteNodeInfo(nodeInfo *DBNodeInfo) error
DeleteNodeInfo delete node info from database
func (*Client) GetAccountByAddress ¶
GetAccountByAddress get an dbaccount by account address
func (*Client) GetAccountCnt ¶
GetAccountCnt get account count
func (*Client) GetAccountCntByShardNumber ¶
GetAccountCntByShardNumber get contract count
func (*Client) GetAccountsByHome ¶
GetAccountsByHome get an dbaccount list sort by balance
func (*Client) GetAccountsByShardNumber ¶
GetAccountsByShardNumber get an dbaccount list sort by balance
func (*Client) GetBlockByHash ¶
GetBlockByHash get a block from mongo by block header hash
func (*Client) GetBlockByHeight ¶
GetBlockByHeight get block from mongo by block height
func (*Client) GetBlockCnt ¶
GetBlockCnt get row count of transaction table from mongo
func (*Client) GetBlockHeight ¶
GetBlockHeight get row count of block table from mongo
func (*Client) GetBlockProTime ¶
GetBlockProTime gets the information of last two blocks
func (*Client) GetBlockTxsTps ¶
GetBlockTxsTps From a block transaction throughput TPS
func (*Client) GetBlockfee ¶
GetBlockfee get the total fee of the block
func (*Client) GetBlocksByHeight ¶
GetBlocksByHeight get a block list from mongo by height range
func (*Client) GetBlocksByTime ¶
GetBlocksByTime get a block list from mongo by time period
func (*Client) GetContractCnt ¶
GetContractCnt get contract count
func (*Client) GetContractCntByShardNumber ¶
GetContractCntByShardNumber get contract count
func (*Client) GetContractsByShardNumber ¶
GetContractsByShardNumber get the contracts number by shard number
func (*Client) GetDebtByHash ¶
GetDebtByHash get debt info by hash from mongo
func (*Client) GetHashRateChart ¶
func (c *Client) GetHashRateChart() ([]*DBOneDayHashRate, error)
GetHashRateChart get all rows int the hashrate table
func (*Client) GetHashRateChartByShardNumber ¶
func (c *Client) GetHashRateChartByShardNumber(shardNumber int) ([]*DBOneDayHashRate, error)
GetHashRateChartByShardNumber get ratechart by shardnumber
func (*Client) GetLastBlocksByShard ¶
func (c *Client) GetLastBlocksByShard(shard int) ([]*DBLastBlock, error)
GetLastBlocksByShard get the last blocks by shard number
func (*Client) GetMinedBlocksByShardNumberAndAddress ¶
func (c *Client) GetMinedBlocksByShardNumberAndAddress(shardNumber int, address string) (int64, int64, int64, error)
GetMinedBlocksByShardNumberAndAddress get the blocks number by the miner
func (c *Client) GetMinedBlocksByShardNumberAndAddress(shardNumber int, address string) (int64, int64, int64, error) { var blockCnt, blockFee, blockAmount int64 var blocks []*DBBlock query := func(c *mgo.Collection) error { var err error c.Find(bson.M{"shardNumber": shardNumber, "creator": address}).All(&blocks) blockCnt = int64(len(blocks)) blockFee = 0 for i := 0; i < len(blocks); i++ { for j := 0; j < len(blocks[i].Txs); j++ { data := blocks[i].Txs[j] if len(data.DebtTxHash) > 0 { blockFee += data.Fee / 3 // cross shard txs } else { blockFee += data.Fee } //blockAmount += data.Amount } for j:=0; j< len(blocks[i].Debts); j++ { data := blocks[i].Debts[j] blockFee += data.Fee *2/3 } // TODO: block fee for cross shard destination blockAmount += blocks[i].Reward } return err } err := c.withCollection(blockTbl, query) return blockCnt, blockFee, blockAmount, err }
func (*Client) GetMinedBlocksCntByShardNumberAndAddress ¶
func (c *Client) GetMinedBlocksCntByShardNumberAndAddress(shardNumber int, address string) (int64, error)
GetMinedBlocksCntByShardNumberAndAddress get the blocks number by the miner
func (*Client) GetMinerAccountByAddress ¶
GetMinerAccountByAddress get an dbaccount by account address
func (*Client) GetMinerAccounts ¶
GetMinerAccounts get the size of DBMiner
func (*Client) GetNodeCntByShardNumber ¶
GetNodeCntByShardNumber get row count of the node table
func (*Client) GetNodeInfo ¶
func (c *Client) GetNodeInfo(host string) (*DBNodeInfo, error)
GetNodeInfo get node info from database
func (*Client) GetNodeInfoByID ¶
func (c *Client) GetNodeInfoByID(id string) (*DBNodeInfo, error)
GetNodeInfoByID get node info from database by node id
func (*Client) GetNodeInfos ¶
func (c *Client) GetNodeInfos() ([]*DBNodeInfo, error)
GetNodeInfos get all node infos from database
func (*Client) GetNodeInfosByShardNumber ¶
func (c *Client) GetNodeInfosByShardNumber(shardNumber int) ([]*DBNodeInfo, error)
GetNodeInfosByShardNumber get all node infos from database by shardNumber
func (*Client) GetOneDayAddress ¶
func (c *Client) GetOneDayAddress(shardNumber int, zeroTime int64) (*DBOneDayAddressInfo, error)
GetOneDayAddress get one day block info from mongo by zero hour timestamp
func (*Client) GetOneDayAddressesChart ¶
func (c *Client) GetOneDayAddressesChart() ([]*DBOneDayAddressInfo, error)
GetOneDayAddressesChart get all rows int the address table
func (*Client) GetOneDayAddressesChartByShardNumber ¶
func (c *Client) GetOneDayAddressesChartByShardNumber(shardNumber int) ([]*DBOneDayAddressInfo, error)
GetOneDayAddressesChartByShardNumber get address chart of one day by shard number
func (*Client) GetOneDayBlock ¶
func (c *Client) GetOneDayBlock(shardNumber int, zeroTime int64) (*DBOneDayBlockInfo, error)
GetOneDayBlock get one day block info from mongo by zero hour timestamp
func (*Client) GetOneDayBlockAvgTime ¶
func (c *Client) GetOneDayBlockAvgTime(shardNumber int, zeroTime int64) (*DBOneDayBlockAvgTime, error)
GetOneDayBlockAvgTime get one day avg block time info from mongo by zero hour timestamp
func (*Client) GetOneDayBlockAvgTimeChart ¶
func (c *Client) GetOneDayBlockAvgTimeChart() ([]*DBOneDayBlockAvgTime, error)
GetOneDayBlockAvgTimeChart get all rows int the hashrate table
func (*Client) GetOneDayBlockAvgTimeChartByShardNumber ¶
func (c *Client) GetOneDayBlockAvgTimeChartByShardNumber(shardNumber int) ([]*DBOneDayBlockAvgTime, error)
GetOneDayBlockAvgTimeChartByShardNumber get avg time chart of one day by shard number
func (*Client) GetOneDayBlockDifficulty ¶
func (c *Client) GetOneDayBlockDifficulty(shardNumber int, zeroTime int64) (*DBOneDayBlockDifficulty, error)
GetOneDayBlockDifficulty get one day hashrate info from mongo by zero hour timestamp
func (*Client) GetOneDayBlockDifficultyChart ¶
func (c *Client) GetOneDayBlockDifficultyChart() ([]*DBOneDayBlockDifficulty, error)
GetOneDayBlockDifficultyChart get all rows int the hashrate table
func (*Client) GetOneDayBlockDifficultyChartByShardNumber ¶
func (c *Client) GetOneDayBlockDifficultyChartByShardNumber(shardNumber int) ([]*DBOneDayBlockDifficulty, error)
GetOneDayBlockDifficultyChartByShardNumber get the td chart of block by shard number
func (*Client) GetOneDayBlocksChart ¶
func (c *Client) GetOneDayBlocksChart() ([]*DBOneDayBlockInfo, error)
GetOneDayBlocksChart get all rows int the hashrate table
func (*Client) GetOneDayBlocksChartByShardNumber ¶
func (c *Client) GetOneDayBlocksChartByShardNumber(shardNumber int) ([]*DBOneDayBlockInfo, error)
GetOneDayBlocksChartByShardNumber get block chart of one day by shard number
func (*Client) GetOneDayHashRate ¶
func (c *Client) GetOneDayHashRate(shardNumber int, zeroTime int64) (*DBOneDayHashRate, error)
GetOneDayHashRate get one day hashrate info from mongo by zero hour timestamp
func (*Client) GetOneDaySingleAddressInfo ¶
func (c *Client) GetOneDaySingleAddressInfo(shardNumber int, address string) (*DBOneDaySingleAddressInfo, error)
GetOneDaySingleAddressInfo get one day block info from mongo by zero hour timestamp
func (*Client) GetOneDayTransInfo ¶
func (c *Client) GetOneDayTransInfo(shardNumber int, zeroTime int64) (*DBOneDayTxInfo, error)
GetOneDayTransInfo get one day transaction info from mongo by zero hour timestamp
func (*Client) GetPendingTxByHash ¶
GetPendingTxByHash get pending transactions by hash
func (*Client) GetPendingTxCntByShardNumber ¶
GetPendingTxCntByShardNumber get pending transactions by shard number
func (*Client) GetPendingTxsByAddress ¶
GetPendingTxsByAddress return a pending tx list by address
func (*Client) GetPendingTxsByIdx ¶
GetPendingTxsByIdx get a transaction list from mongo by time period
func (*Client) GetTopMinerChart ¶
func (c *Client) GetTopMinerChart() ([]*DBMinerRankInfo, error)
GetTopMinerChart get all rows int the address table
func (*Client) GetTopMinerChartByShardNumber ¶
func (c *Client) GetTopMinerChartByShardNumber(shardNumber int) ([]*DBMinerRankInfo, error)
GetTopMinerChartByShardNumber get top miner char by shard number
func (*Client) GetTotalBalance ¶
GetTotalBalance return the sum of all account
func (*Client) GetTransInfoChart ¶
func (c *Client) GetTransInfoChart() ([]*DBOneDayTxInfo, error)
GetTransInfoChart get all rows int the transhistory table
func (*Client) GetTransInfoChartByShardNumber ¶
func (c *Client) GetTransInfoChartByShardNumber(shardNumber int) ([]*DBOneDayTxInfo, error)
GetTransInfoChartByShardNumber get transactions info chart by shard number
func (*Client) GetTxByHash ¶
GetTxByHash get transaction info by hash from mongo
func (*Client) GetTxByIdx ¶
GetTxByIdx get transaction from mongo by idx
func (*Client) GetTxCntAndAccTypeByAddressFromAccount ¶
func (*Client) GetTxCntByAddressFromAccount ¶
GetTxCnt get current count from account table from mongo
func (*Client) GetTxCntByShardNumber ¶
GetTxCntByShardNumber get tx count by shardNumber
func (*Client) GetTxCntByShardNumberAndAddress ¶
GetTxCntByShardNumberAndAddress get tx count for the account
func (*Client) GetTxHis ¶
func (c *Client) GetTxHis(startDate, today string) ([]*DBSimpleTxs, error)
GetTxHis get transaction history
func (*Client) GetTxHisCntByDate ¶
GetTxHisCntByDate get transaction history count by date
func (*Client) GetTxs ¶
func (c *Client) GetTxs(shardNumber int, sort string, desc bool, limit int, skip int) ([]*DBTx, error)
GetTxs get transactions from transaction table given shardNumber, sort field, limit and skip if sort is null, the result will not be sort by any fields if limit <=0 , the result will get all the records if skip <=0, the result will get records from the first one
func (*Client) GetTxsByAddresses ¶
GetTxsByAddresses return a tx list by address
func (*Client) GetTxsByIdx ¶
GetTxsByIdx get a transaction list from mongo by time period
func (*Client) GetTxsDayCount ¶
GetTxsDayCount get row count of transaction table from mongo
func (*Client) GetTxsinfoByDate ¶
GetTxsinfoByDate get row count of the transaction table
func (*Client) GetblockdebtCntByShardNumber ¶
GetblockdebtCntByShardNumber get block from mongo by block height
func (*Client) GetblockdebtsByIdx ¶
func (c *Client) GetblockdebtsByIdx(shardNumber int, height uint64, begin uint64, end uint64) ([]*Debt, error)
GetblockdebtsByIdx get a debt list from mongo by time period
func (*Client) GetdebtCntByShardNumber ¶
GetdebtCntByShardNumber get tx count by shardNumber
func (*Client) GetdebtsByIdx ¶
GetdebtsByIdx get a debt list from mongo by time period
func (*Client) InitTxCntByShardNumber ¶
func (*Client) LiveServers ¶
LiveServers return the URLs of the alive servers
func (*Client) RemoveAllPendingTxs ¶
RemoveAllPendingTxs remove all pending transactions
func (*Client) RemoveBlock ¶
RemoveBlock test use remove block by height from database
func (*Client) RemoveLastBlocksByShard ¶
RemoveLastBlocksByShard remove the last blocks by shard number
func (*Client) RemoveOutDateByDate ¶
RemoveOutDateByDate remove the outdate data by date
func (*Client) RemoveTopMinerInfo ¶
RemoveTopMinerInfo remove last 7 days top miner info
func (*Client) SetPrimaryMode ¶
func (c *Client) SetPrimaryMode()
SetPrimaryMode set the primary mode for mongodb
func (*Client) SetSecondaryPreferredMode ¶
func (c *Client) SetSecondaryPreferredMode()
SetSecondaryPreferredMode set the SecondaryPreferred mode for mongodb
func (*Client) UpdateAccount ¶
UpdateAccount update account
func (*Client) UpdateAccountMinedBlock ¶
UpdateAccountMinedBlock update field mined block in the account info
func (*Client) UpdateBlock ¶
UpdateBlock update block by height and shard from database
func (*Client) UpdateLastBlock ¶
func (c *Client) UpdateLastBlock(height int64, block *DBLastBlock) error
UpdateLastBlock update the last block
func (*Client) UpdateMinerAccount ¶
UpdateMinerAccount update account
func (*Client) UpdateTxsCntByDate ¶
func (c *Client) UpdateTxsCntByDate(tx *DBSimpleTxs) error
UpdateTxsCntByDate get transaction count by date
type DBAccount ¶
type DBAccount struct { AccType int `bson:"accType"` //0 is normal account, 1 is contract account Address string `bson:"address"` Balance int64 `bson:"balance"` ShardNumber int `bson:"shardNumber"` TxCount int64 `bson:"txCount"` TimeStamp int64 `bson:"timestamp"` }
DBAccount describle a account which stored in the database
func CreateEmptyAccount ¶
CreateEmptyAccount create an empty dbaccount
type DBBlock ¶
type DBBlock struct { HeadHash string `bson:"headHash"` PreHash string `bson:"preBlockHash"` Height int64 `bson:"height"` StateHash string `bson:"stateHash"` Timestamp int64 `bson:"timestamp"` Difficulty string `bson:"difficulty"` TotalDifficulty string `bson:"totalDifficulty"` Creator string `bson:"creator"` Nonce string `bson:"nonce"` TxHash string `bson:"txHash"` Reward int64 `bson:"reward"` UsedGas int64 `bson:"usedGas"` Txs []DBSimpleTxInBlock `bson:"transactions"` Debts []DBSimpleDebtInBlock `bson:"debt"` TxDebts []DBSimpleDebtInBlock `bson:"txDebt"` ShardNumber int `bson:"shardNumber"` }
DBBlock describle the block info which stored in the database
func CreateDbBlock ¶
CreateDbBlock convert an rpc block to an dbblock
type DBLastBlock ¶
type DBLastBlock struct { ShardNumber int `bson:"shardNumber"` Height int64 `bson:"height"` Timestamp int64 `bson:"timestamp"` TxNumber int `bson:"txNumber"` }
DBLastBlock contains the last block information
type DBMiner ¶
type DBMiner struct { Address string `bson:"address"` Revenue int64 `bson:"total"` ShardNumber int `bson:"shardNumber"` Reward int64 `bson:"reward"` TxFee int64 `bson:"fee"` TimeStamp int64 `bson:"timestamp"` Mined int64 `bson:"mined"` }
DBMiner describle a miner account which stored in the database
type DBMinerRankInfo ¶
type DBMinerRankInfo struct { Rank []DBSingleMinerRankInfo `bson:"rank"` ShardNumber int `bson:"shardnumber"` }
DBMinerRankInfo descible top miner rank
type DBNodeInfo ¶
type DBNodeInfo struct { ShardNumber int `bson:"shardNumber"` ID string `bson:"id"` Host string `bson:"host"` Port string `bson:"port"` City string `bson:"city"` Region string `bson:"region"` Country string `bson:"country"` Client string `bson:"client"` Caps string `bson:"caps"` LastSeen int64 `bson:"lastseen"` LongitudeAndLatitude string `bson:"longitudeandlatitude"` }
DBNodeInfo descible an single node in the network
type DBOneDayAddressInfo ¶
type DBOneDayAddressInfo struct { TotalAddresss int64 `bson:"totaladdresss"` TodayIncrease int64 `bson:"todayincrease"` TimeStamp int64 `bson:"timestamp"` ShardNumber int `bson:"shardnumber"` }
DBOneDayAddressInfo describle all blocks in an single day
type DBOneDayBlockAvgTime ¶
type DBOneDayBlockAvgTime struct { AvgTime float64 `bson:"avgtime"` TimeStamp int64 `bson:"timestamp"` ShardNumber int `bson:"shardnumber"` }
DBOneDayBlockAvgTime describle avg block time in an single day
type DBOneDayBlockDifficulty ¶
type DBOneDayBlockDifficulty struct { Difficulty float64 `bson:"difficulty"` TimeStamp int64 `bson:"timestamp"` ShardNumber int `bson:"shardnumber"` }
DBOneDayBlockDifficulty describle avg block difficulty in an single day
type DBOneDayBlockInfo ¶
type DBOneDayBlockInfo struct { TotalBlocks int64 `bson:"totalblocks"` Rewards int64 `bson:"rewards"` TimeStamp int64 `bson:"timestamp"` ShardNumber int `bson:"shardnumber"` }
DBOneDayBlockInfo describle all blocks in an single day
type DBOneDayHashRate ¶
type DBOneDayHashRate struct { HashRate float64 `bson:"hashrate"` TimeStamp int64 `bson:"timestamp"` ShardNumber int `bson:"shardnumber"` }
DBOneDayHashRate describle all hashrates in an single day
type DBOneDaySingleAddressInfo ¶
type DBOneDaySingleAddressInfo struct { Address string `bson:"address"` TimeStamp int64 `bson:"timestamp"` ShardNumber int `bson:"shardnumber"` }
DBOneDaySingleAddressInfo describle one day single address info
type DBOneDayTxInfo ¶
type DBOneDayTxInfo struct { TotalTxs int `bson:"totaltxs"` TotalBlocks int `bson:"totalblocks"` TimeStamp int64 `bson:"timestamp"` ShardNumber int `bson:"shardnumber"` }
DBOneDayTxInfo describle all transactions in an single day
type DBSimpleDebtInBlock ¶
type DBSimpleTxInBlock ¶
type DBSimpleTxInBlock struct { Hash string `bson:"hash"` From string `bson:"from"` To string `bson:"to"` Amount int64 `bson:"amount"` Timestamp string `bson:"timestamp"` Fee int64 `bson:"fee"` GasPrice int64 `bson:"gasPrice"` GasLimit int64 `bson:"gasLimit"` DebtTxHash string `bson:"debtTxHash"` }
DBSimpleTxInBlock describle the transaction info contained by dbblock which stored in the database
type DBSimpleTxs ¶
type DBSingleMinerRankInfo ¶
type DBSingleMinerRankInfo struct { Address string `bson:"address"` Mined int `bson:"mined"` Percentage float64 `bson:"percentage"` }
DBSingleMinerRankInfo describle single miner rank info
type DBTx ¶
type DBTx struct { TxType int `bson:"txtype"` // 0 is an normal transaction, 1 is an create contract transaction Hash string `bson:"hash"` DebtTxHash string `bson:"debtTxHash"` From string `bson:"from"` To string `bson:"to"` Amount int64 `bson:"amount"` AccountNonce string `bson:"accountNonce"` Timestamp string `bson:"timestamp"` Timetxs string `bson:"timetxs"` Payload string `bson:"payload"` Block uint64 `bson:"block"` Idx int64 `bson:"idx"` ShardNumber int `bson:"shardNumber"` Fee int64 `bson:"fee"` GasPrice int64 `bson:"gasPrice"` GasLimit int64 `bson:"gasLimit"` UsedGas int64 `bson:"usedGas"` Pending bool `bson:"pending"` ContractAddress string `bson:"contractAddress"` Receipt rpc.Receipt `bson:"receipt"` }
DBTx describle a transaction which stored in the database
func CreateDbTx ¶
func CreateDbTx(t rpc.Transaction) *DBTx
CreateDbTx convert an rpc transaction to an dbtransaction
type Debt ¶
type Debt struct { Hash string `bson:"hash"` TxHash string `bson:"txhash"` From string `bson:"from"` To string `bson:"to"` Height uint64 `bson:"height"` Idx uint64 `bson:"idx"` ShardNumber int `bson:"shardNumber"` Fee int64 `bson:"fee"` Payload string `bson:"payload"` Amount int64 `bson:"amount"` }
Debt describle a transaction which stored in the database
func CreateDebtTx ¶
CreateDebtTx convert an rpc transaction to an dbtransaction