davec nits

This commit is contained in:
Marco Peereboom 2017-02-16 11:29:55 -06:00
parent 4b2c7cbf0d
commit 5205214013
3 changed files with 14 additions and 13 deletions

View File

@ -12,7 +12,7 @@ type GetStakeDifficultyResult struct {
NextStakeDifficulty float64 `json:"next"`
}
// VersionCount models a generic version:count tupple.
// VersionCount models a generic version:count tuple.
type VersionCount struct {
Version uint32 `json:"version"`
Count uint32 `json:"count"`
@ -60,7 +60,7 @@ type Choice struct {
Progress float64 `json:"progress"`
}
// Agenda models an individual agenda including it's choices.
// Agenda models an individual agenda including its choices.
type Agenda struct {
Id string `json:"id"`
Description string `json:"description"`

View File

@ -3864,7 +3864,7 @@ func convertVersionMap(m map[int]int) []dcrjson.VersionCount {
// handleGetStakeVersionInfo implements the getstakeversioninfo command.
func handleGetStakeVersionInfo(s *rpcServer, cmd interface{}, closeChan <-chan struct{}) (interface{}, error) {
count := int32(0)
count := int32(1)
c, ok := cmd.(*dcrjson.GetStakeVersionInfoCmd)
if !ok {
return nil, internalRPCError("Invalid command",
@ -3872,9 +3872,10 @@ func handleGetStakeVersionInfo(s *rpcServer, cmd interface{}, closeChan <-chan s
}
if c.Count != nil {
count = *c.Count
}
if count == 0 {
count = 1
if count <= 0 {
return nil, internalRPCError("Invalid count",
"handleGetStakeVersionInfo")
}
}
snapshot := s.chain.BestSnapshot()
@ -3891,17 +3892,17 @@ func handleGetStakeVersionInfo(s *rpcServer, cmd interface{}, closeChan <-chan s
endHeight := s.chain.CalcWantHeight(interval,
snapshot.Height) + 1
hash := snapshot.Hash
adjust := int32(1) // we are off by one on the initial iteration.
adjust := int32(1) // We are off by one on the initial iteration.
for i := int32(0); i < count; i++ {
numBlocks := int32(startHeight - endHeight)
if numBlocks <= 0 {
// Just return what we got.
return result, nil
break
}
sv, err := s.chain.GetStakeVersions(hash, numBlocks+adjust)
if err != nil {
// Just return what we got.
return result, nil
return nil, internalRPCError(err.Error(),
"handleGetStakeVersionInfo")
}
posVersions := make(map[int]int)
@ -3928,8 +3929,8 @@ func handleGetStakeVersionInfo(s *rpcServer, cmd interface{}, closeChan <-chan s
// Get prior block hash.
hash, err = s.chain.BlockHashByHeight(startHeight - 1)
if err != nil {
// Just return what we got.
return result, nil
return nil, internalRPCError(err.Error(),
"handleGetStakeVersionInfo")
}
}

View File

@ -409,7 +409,7 @@ var helpDescsEnUS = map[string]string{
"getstakedifficultyresult-next": "The calculated stake difficulty of the next block",
// GetStakeVersionInfoCmd help.
"getstakeversioninfo--synopsis": "Returns the stake versions statistics.",
"getstakeversioninfo--synopsis": "Returns stake version statistics for one or more stake version intervals.",
"getstakeversioninfo-count": "Number of intervals to return.",
"getstakeversioninforesult-currentheight": "Top of the chain height.",
"getstakeversioninforesult-hash": "Top of the chain hash.",