Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: modify pov repstats response #42

Merged
merged 1 commit into from
Dec 30, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions pov.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,25 @@ type PovMinerStats struct {
LatestBlockHeight uint64 `json:"latestBlockHeight"`
}

type PovRepStats struct {
type PovRepStatItem struct {
MainBlockNum uint32 `json:"mainBlockNum"`
MainRewardAmount types.Balance `json:"mainRewardAmount"`
MainOnlinePeriod uint32 `json:"mainOnlinePeriod"`
StableBlockNum uint32 `json:"stableBlockNum"`
StableRewardAmount types.Balance `json:"stableRewardAmount"`
StableOnlinePeriod uint32 `json:"stableOnlinePeriod"`
LastOnlineTime time.Time `json:"lastOnlineTime"`
LastOnlineHeight uint64 `json:"lastOnlineHeight"`
IsOnline bool `json:"isOnline"`
}

type PovRepStats struct {
RepCount uint32 `json:"repCount"`
RepStats map[types.Address]*PovRepStatItem `json:"repStats"`
TotalBlockNum uint32 `json:"totalBlockNum"`
TotalPeriod uint32 `json:"totalPeriod"`
TotalRewardAmount types.Balance `json:"totalRewardAmount"`
LatestBlockHeight uint64 `json:"latestBlockHeight"`
}

type PovApiGetLastNHourItem struct {
Expand Down Expand Up @@ -402,13 +416,13 @@ func (p *PovApi) GetDiffDayStatByHeight(height uint64) (*types.PovDiffDayStat, e
}

// GetRepStats returns pov rep statistic
func (p *PovApi) GetRepStats(addrs []types.Address) (map[types.Address]*PovRepStats, error) {
var rspData map[types.Address]*PovRepStats
func (p *PovApi) GetRepStats(addrs []types.Address) (*PovRepStats, error) {
var rspData PovRepStats
err := p.client.Call(&rspData, "pov_getRepStats", addrs)
if err != nil {
return nil, err
}
return rspData, nil
return &rspData, nil
}

// GetLastNHourInfo returns pov last n hour statistic
Expand Down