Skip to content

Commit

Permalink
Return vspd version. (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
jholdstock authored Jul 15, 2021
1 parent e39f43e commit dddf21e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type Vsp struct {
Voting int64 `json:"voting"`
Voted int64 `json:"voted"`
Revoked int64 `json:"revoked"`
VspdVersion string `json:"vspdversion"`
}
type vspSet map[string]Vsp

Expand Down Expand Up @@ -607,9 +608,10 @@ func vspStats(service *Service, url string) error {
voting, hasVoting := info["voting"]
voted, hasVoted := info["voted"]
revoked, hasRevoked := info["revoked"]
version, hasVersion := info["vspdversion"]

hasRequiredFields := hasAPIVersions && hasFeePercentage &&
hasClosed && hasVoting && hasVoted && hasRevoked
hasClosed && hasVoting && hasVoted && hasRevoked && hasVersion

if !hasRequiredFields {
return fmt.Errorf("%v: missing required fields: %+v", infoURL, info)
Expand All @@ -625,6 +627,7 @@ func vspStats(service *Service, url string) error {
vsp.Voting = int64(voting.(float64))
vsp.Voted = int64(voted.(float64))
vsp.Revoked = int64(revoked.(float64))
vsp.VspdVersion = version.(string)

vsp.LastUpdated = time.Now().Unix()

Expand All @@ -637,9 +640,9 @@ func vspStats(service *Service, url string) error {

func vspData(service *Service) {
var waitGroup sync.WaitGroup
waitGroup.Add(len(service.Vsps))
for url := range service.Vsps {
go func(url string) {
waitGroup.Add(1)
defer waitGroup.Done()
err := vspStats(service, url)
if err != nil {
Expand Down

0 comments on commit dddf21e

Please sign in to comment.