Cleanup api types
This commit is contained in:
parent
65383c34c3
commit
4a92d3a727
|
@ -367,14 +367,14 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
var foundBlocksData [index.InclusionAlternateInVerifiedChain + 1]utils2.MinerInfoBlockData
|
||||
var foundBlocksData [index.InclusionCount]utils2.MinerInfoBlockData
|
||||
_ = indexDb.Query("SELECT COUNT(*) as count, coalesce(MAX(side_height), 0) as last_height, inclusion FROM side_blocks WHERE side_blocks.miner = $1 GROUP BY side_blocks.inclusion ORDER BY inclusion ASC;", func(row index.RowScanInterface) error {
|
||||
var d utils2.MinerInfoBlockData
|
||||
var inclusion index.BlockInclusion
|
||||
if err := row.Scan(&d.ShareCount, &d.LastShareHeight, &inclusion); err != nil {
|
||||
return err
|
||||
}
|
||||
if inclusion < 3 {
|
||||
if inclusion < index.InclusionCount {
|
||||
foundBlocksData[inclusion] = d
|
||||
}
|
||||
return nil
|
||||
|
@ -386,7 +386,7 @@ func main() {
|
|||
if err := row.Scan(&d.ShareCount, &d.LastShareHeight, &inclusion); err != nil {
|
||||
return err
|
||||
}
|
||||
if inclusion <= index.InclusionAlternateInVerifiedChain {
|
||||
if inclusion < index.InclusionCount {
|
||||
foundBlocksData[inclusion].ShareCount -= d.ShareCount
|
||||
foundBlocksData[inclusion].UncleCount = d.ShareCount
|
||||
}
|
||||
|
|
|
@ -67,11 +67,20 @@ type PoolInfoResultSideChain struct {
|
|||
Effort PoolInfoResultSideChainEffort `json:"effort"`
|
||||
Window PoolInfoResultSideChainWindow `json:"window"`
|
||||
WindowSize int `json:"window_size"`
|
||||
MaxWindowSize int `json:"max_window_size"`
|
||||
BlockTime int `json:"block_time"`
|
||||
UnclePenalty int `json:"uncle_penalty"`
|
||||
Found uint64 `json:"found"`
|
||||
Miners uint64 `json:"miners"`
|
||||
|
||||
// MaxWindowSize Available on Consensus
|
||||
// Deprecated
|
||||
MaxWindowSize int `json:"max_window_size"`
|
||||
|
||||
// BlockTime Available on Consensus
|
||||
// Deprecated
|
||||
BlockTime int `json:"block_time"`
|
||||
|
||||
// UnclePenalty Available on Consensus
|
||||
// Deprecated
|
||||
UnclePenalty int `json:"uncle_penalty"`
|
||||
}
|
||||
|
||||
type PoolInfoResultSideChainEffort struct {
|
||||
|
@ -106,10 +115,10 @@ type MinerInfoBlockData struct {
|
|||
}
|
||||
|
||||
type MinerInfoResult struct {
|
||||
Id uint64 `json:"id"`
|
||||
Address *address.Address `json:"address"`
|
||||
Alias string `json:"alias,omitempty"`
|
||||
Shares [index.InclusionAlternateInVerifiedChain + 1]MinerInfoBlockData `json:"shares"`
|
||||
LastShareHeight uint64 `json:"last_share_height"`
|
||||
LastShareTimestamp uint64 `json:"last_share_timestamp"`
|
||||
Id uint64 `json:"id"`
|
||||
Address *address.Address `json:"address"`
|
||||
Alias string `json:"alias,omitempty"`
|
||||
Shares [index.InclusionCount]MinerInfoBlockData `json:"shares"`
|
||||
LastShareHeight uint64 `json:"last_share_height"`
|
||||
LastShareTimestamp uint64 `json:"last_share_timestamp"`
|
||||
}
|
||||
|
|
|
@ -1442,7 +1442,7 @@ func main() {
|
|||
ctx["last_orphaned_shares"] = lastOrphanedShares
|
||||
|
||||
if windowDiff.Cmp64(0) > 0 {
|
||||
longWindowWeight := poolInfo.SideChain.Window.Weight.Mul64(4).Mul64(uint64(poolInfo.SideChain.MaxWindowSize)).Div64(uint64(poolInfo.SideChain.WindowSize))
|
||||
longWindowWeight := poolInfo.SideChain.Window.Weight.Mul64(4).Mul64(poolInfo.SideChain.Consensus.ChainWindowSize).Div64(uint64(poolInfo.SideChain.WindowSize))
|
||||
averageRewardPerBlock := longDiff.Mul64(poolInfo.MainChain.BaseReward).Div(longWindowWeight).Lo
|
||||
expectedRewardPerDay := longWindowWeight.Mul64(averageRewardPerBlock).Div(poolInfo.MainChain.NextDifficulty).Lo
|
||||
ctx["expected_reward_per_day"] = expectedRewardPerDay
|
||||
|
@ -1464,7 +1464,7 @@ func main() {
|
|||
ctx["position_uncles"] = unclesFound.StringWithSeparator(int(consensus.ChainWindowSize*totalWindows - currentWindowSize))
|
||||
ctx["position_payouts"] = foundPayout.StringWithSeparator(int(consensus.ChainWindowSize*totalWindows - currentWindowSize))
|
||||
|
||||
totalWeight := poolInfo.SideChain.Window.Weight.Mul64(4).Mul64(uint64(poolInfo.SideChain.MaxWindowSize)).Div64(uint64(poolInfo.SideChain.WindowSize))
|
||||
totalWeight := poolInfo.SideChain.Window.Weight.Mul64(4).Mul64(poolInfo.SideChain.Consensus.ChainWindowSize).Div64(uint64(poolInfo.SideChain.WindowSize))
|
||||
dailyHashRate := poolInfo.SideChain.Difficulty.Mul(longDiff).Div(totalWeight).Div64(consensus.TargetBlockTime).Lo
|
||||
|
||||
hashRate := float64(0)
|
||||
|
|
|
@ -21,6 +21,8 @@ const (
|
|||
InclusionInVerifiedChain
|
||||
// InclusionAlternateInVerifiedChain alternate in-verified-chain (uncle or main), for example when duplicate nonce happens
|
||||
InclusionAlternateInVerifiedChain
|
||||
|
||||
InclusionCount
|
||||
)
|
||||
|
||||
const SideBlockSelectFields = "main_id, main_height, template_id, side_height, parent_template_id, miner, uncle_of, effective_height, nonce, extra_nonce, timestamp, software_id, software_version, window_depth, window_outputs, transaction_count, difficulty, cumulative_difficulty, pow_difficulty, pow_hash, inclusion"
|
||||
|
|
Loading…
Reference in a new issue