database

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2019 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

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

func (c *Client) AddAccount(account *DBAccount) error

AddAccount insert an account into database

func (*Client) AddBlock

func (c *Client) AddBlock(b *DBBlock) error

AddBlock insert a block into database

func (*Client) AddDebtTxs

func (c *Client) AddDebtTxs(debttxs ...interface{}) error

AddDebtTxs insert a transaction into mongo

func (*Client) AddLastBlocks

func (c *Client) AddLastBlocks(blocks ...interface{}) error

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

func (c *Client) AddPendingTx(tx *DBTx) error

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) AddTx

func (c *Client) AddTx(tx *DBTx) error

AddTx insert a transaction into mongo

func (*Client) AddTxs

func (c *Client) AddTxs(txs ...interface{}) error

AddTxs insert batch of transactions into mongo

func (*Client) DeleteNodeInfo

func (c *Client) DeleteNodeInfo(nodeInfo *DBNodeInfo) error

DeleteNodeInfo delete node info from database

func (*Client) GetAccountByAddress

func (c *Client) GetAccountByAddress(address string) (*DBAccount, error)

GetAccountByAddress get an dbaccount by account address

func (*Client) GetAccountCnt

func (c *Client) GetAccountCnt() (uint64, error)

GetAccountCnt get account count

func (*Client) GetAccountCntByShardNumber

func (c *Client) GetAccountCntByShardNumber(shardNumber int) (uint64, error)

GetAccountCntByShardNumber get contract count

func (*Client) GetAccountsByHome

func (c *Client) GetAccountsByHome() []*DBAccount

GetAccountsByHome get an dbaccount list sort by balance

func (*Client) GetAccountsByShardNumber

func (c *Client) GetAccountsByShardNumber(shardNumber int, max int) ([]*DBAccount, error)

GetAccountsByShardNumber get an dbaccount list sort by balance

func (*Client) GetBlockByHash

func (c *Client) GetBlockByHash(hash string) (*DBBlock, error)

GetBlockByHash get a block from mongo by block header hash

func (*Client) GetBlockByHeight

func (c *Client) GetBlockByHeight(shardNumber int, height uint64) (*DBBlock, error)

GetBlockByHeight get block from mongo by block height

func (*Client) GetBlockCnt

func (c *Client) GetBlockCnt() (uint64, error)

GetBlockCnt get row count of transaction table from mongo

func (*Client) GetBlockHeight

func (c *Client) GetBlockHeight(shardNumber int) (uint64, error)

GetBlockHeight get row count of block table from mongo

func (*Client) GetBlockProTime

func (c *Client) GetBlockProTime() (int64, int64, error)

GetBlockProTime gets the information of last two blocks

func (*Client) GetBlockTxsTps

func (c *Client) GetBlockTxsTps() (float64, error)

GetBlockTxsTps From a block transaction throughput TPS

func (*Client) GetBlockfee

func (c *Client) GetBlockfee(block uint64) (int64, error)

GetBlockfee get the total fee of the block

func (*Client) GetBlocksByHeight

func (c *Client) GetBlocksByHeight(shardNumber int, begin uint64, end uint64) ([]*DBBlock, error)

GetBlocksByHeight get a block list from mongo by height range

func (*Client) GetBlocksByTime

func (c *Client) GetBlocksByTime(shardNumber int, beginTime, endTime int64) ([]*DBBlock, error)

GetBlocksByTime get a block list from mongo by time period

func (*Client) GetContractCnt

func (c *Client) GetContractCnt() (uint64, error)

GetContractCnt get contract count

func (*Client) GetContractCntByShardNumber

func (c *Client) GetContractCntByShardNumber(shardNumber int) (uint64, error)

GetContractCntByShardNumber get contract count

func (*Client) GetContractsByShardNumber

func (c *Client) GetContractsByShardNumber(shardNumber int, max int) ([]*DBAccount, error)

GetContractsByShardNumber get the contracts number by shard number

func (*Client) GetDebtByHash

func (c *Client) GetDebtByHash(hash string) (*Debt, error)

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

func (c *Client) GetMinerAccountByAddress(address string) (*DBMiner, error)

GetMinerAccountByAddress get an dbaccount by account address

func (*Client) GetMinerAccounts

func (c *Client) GetMinerAccounts(size int) ([]*DBMiner, error)

GetMinerAccounts get the size of DBMiner

func (*Client) GetNodeCntByShardNumber

func (c *Client) GetNodeCntByShardNumber(shardNumber int) (uint64, error)

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

func (c *Client) GetPendingTxByHash(hash string) (*DBTx, error)

GetPendingTxByHash get pending transactions by hash

func (*Client) GetPendingTxCntByShardNumber

func (c *Client) GetPendingTxCntByShardNumber(shardNumber int) (uint64, error)

GetPendingTxCntByShardNumber get pending transactions by shard number

func (*Client) GetPendingTxsByAddress

func (c *Client) GetPendingTxsByAddress(address string) ([]*DBTx, error)

GetPendingTxsByAddress return a pending tx list by address

func (*Client) GetPendingTxsByIdx

func (c *Client) GetPendingTxsByIdx(shardNumber int, begin uint64, end uint64) ([]*DBTx, error)

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

func (c *Client) GetTotalBalance() (map[int]int64, error)

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

func (c *Client) GetTxByHash(hash string) (*DBTx, error)

GetTxByHash get transaction info by hash from mongo

func (*Client) GetTxByIdx

func (c *Client) GetTxByIdx(idx uint64) (*DBTx, error)

GetTxByIdx get transaction from mongo by idx

func (*Client) GetTxCnt

func (c *Client) GetTxCnt() (uint64, error)

GetTxCnt get row count of transaction table from mongo

func (*Client) GetTxCntAndAccTypeByAddressFromAccount

func (c *Client) GetTxCntAndAccTypeByAddressFromAccount(address string) (int64, int, error)

func (*Client) GetTxCntByAddressFromAccount

func (c *Client) GetTxCntByAddressFromAccount(address string) (int64, error)

GetTxCnt get current count from account table from mongo

func (*Client) GetTxCntByShardNumber

func (c *Client) GetTxCntByShardNumber(shardNumber int) (uint64, error)

GetTxCntByShardNumber get tx count by shardNumber

func (*Client) GetTxCntByShardNumberAndAddress

func (c *Client) GetTxCntByShardNumberAndAddress(shardNumber int, address string) (int64, error)

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

func (c *Client) GetTxHisCntByDate(date string) (uint64, error)

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

func (c *Client) GetTxsByAddresses(address string, asc bool, limit int, skip int) ([]*DBTx, error)

GetTxsByAddresses return a tx list by address

func (*Client) GetTxsByIdx

func (c *Client) GetTxsByIdx(shardNumber int, begin uint64, end uint64) ([]*DBTx, error)

GetTxsByIdx get a transaction list from mongo by time period

func (*Client) GetTxsDayCount

func (c *Client) GetTxsDayCount() ([]*DBTx, error)

GetTxsDayCount get row count of transaction table from mongo

func (*Client) GetTxsinfoByDate

func (c *Client) GetTxsinfoByDate(date string) (int64, int64, int64, int64, error)

GetTxsinfoByDate get row count of the transaction table

func (*Client) GetblockdebtCntByShardNumber

func (c *Client) GetblockdebtCntByShardNumber(shardNumber int, height uint64) (uint64, error)

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

func (c *Client) GetdebtCntByShardNumber(shardNumber int) (uint64, error)

GetdebtCntByShardNumber get tx count by shardNumber

func (*Client) GetdebtsByIdx

func (c *Client) GetdebtsByIdx(shardNumber int, begin uint64, end uint64) ([]*Debt, error)

GetdebtsByIdx get a debt list from mongo by time period

func (*Client) InitTxCntByShardNumber

func (c *Client) InitTxCntByShardNumber(shardNumber int) error

func (*Client) LiveServers

func (c *Client) LiveServers() []string

LiveServers return the URLs of the alive servers

func (*Client) RemoveAllPendingTxs

func (c *Client) RemoveAllPendingTxs() error

RemoveAllPendingTxs remove all pending transactions

func (*Client) RemoveBlock

func (c *Client) RemoveBlock(shard int, height uint64) error

RemoveBlock test use remove block by height from database

func (*Client) RemoveLastBlocksByShard

func (c *Client) RemoveLastBlocksByShard(shard int) error

RemoveLastBlocksByShard remove the last blocks by shard number

func (*Client) RemoveOutDateByDate

func (c *Client) RemoveOutDateByDate(date string) error

RemoveOutDateByDate remove the outdate data by date

func (*Client) RemoveTopMinerInfo

func (c *Client) RemoveTopMinerInfo() error

RemoveTopMinerInfo remove last 7 days top miner info

func (*Client) RemoveTxs

func (c *Client) RemoveTxs(shard int, blockHeight uint64) error

RemoveTxs Txs by block height

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

func (c *Client) UpdateAccount(account *DBAccount) error

UpdateAccount update account

func (*Client) UpdateAccountMinedBlock

func (c *Client) UpdateAccountMinedBlock(address string, mined int64) error

UpdateAccountMinedBlock update field mined block in the account info

func (*Client) UpdateBlock

func (c *Client) UpdateBlock(shard int, height uint64, b *DBBlock) error

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

func (c *Client) UpdateMinerAccount(miner *DBMiner) error

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

func CreateEmptyAccount(address string, shardNumber int) *DBAccount

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

func CreateDbBlock(b *rpc.BlockInfo) *DBBlock

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 DBSimpleDebtInBlock struct {
	Hash        string `bson:"hash"`
	TxHash      string `bson:"txHash"`
	ShardNumber int    `bson:"shardNumber"`
	Account     string `bson:"account"`
	Amount      int64  `bson:"amount"`
	Fee         int64  `bson:"fee"`
	Payload     string `bson:"payload"`
}

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 DBSimpleTxs struct {
	Stime        string `json:"stime"`
	TxCount      int    `json:"txcount"`
	GasPrice     int64  `json:"gasprice"`
	HighGasPrice int64  `json:"highGasPrice"`
	LowGasPrice  int64  `json:"lowGasPrice"`
}

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

func CreateDebtTx(t rpc.Debt) *Debt

CreateDebtTx convert an rpc transaction to an dbtransaction

Jump to

Keyboard shortcuts

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