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

Return vspd version. #144

Merged
merged 1 commit into from
Jul 15, 2021
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
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