Skip to content

Commit db79ec4

Browse files
authored
Don't expect VSPs to have "revoked". (#198)
This was deprecated in vspd 1.2 and removed in 1.3.
1 parent 11a37a4 commit db79ec4

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

docs/api.md

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Example: <https://api.decred.org/?c=vsp>
2626
"closed": false,
2727
"voting": 3935,
2828
"voted": 57073,
29-
"revoked": 83,
3029
"expired": 73,
3130
"missed": 10,
3231
},

service.go

+5-18
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2017-2024 The Decred developers
1+
// Copyright (c) 2017-2025 The Decred developers
22
// Use of this source code is governed by an ISC
33
// license that can be found in the LICENSE file.
44

@@ -33,7 +33,6 @@ type Vsp struct {
3333
Closed bool `json:"closed"`
3434
Voting int64 `json:"voting"`
3535
Voted int64 `json:"voted"`
36-
Revoked int64 `json:"revoked"`
3736
Expired int64 `json:"expired"`
3837
Missed int64 `json:"missed"`
3938
VspdVersion string `json:"vspdversion"`
@@ -230,16 +229,15 @@ func vspStats(service *Service, url string) error {
230229
vspclosed, hasClosed := info["vspclosed"]
231230
voting, hasVoting := info["voting"]
232231
voted, hasVoted := info["voted"]
233-
revoked, hasRevoked := info["revoked"]
234232
expired, hasExpired := info["expired"]
235233
missed, hasMissed := info["missed"]
236234
version, hasVersion := info["vspdversion"]
237235
blockheight, hasBlockHeight := info["blockheight"]
238236
networkproportion, hasnetworkproportion := info["estimatednetworkproportion"]
239237

240238
hasRequiredFields := hasAPIVersions && hasFeePercentage &&
241-
hasClosed && hasVoting && hasVoted && hasRevoked && hasVersion &&
242-
hasBlockHeight && hasnetworkproportion
239+
hasClosed && hasVoting && hasVoted && hasExpired && hasMissed &&
240+
hasVersion && hasBlockHeight && hasnetworkproportion
243241

244242
if !hasRequiredFields {
245243
return fmt.Errorf("%v: missing required fields: %+v", infoURL, info)
@@ -254,23 +252,12 @@ func vspStats(service *Service, url string) error {
254252
vsp.Closed = vspclosed.(bool)
255253
vsp.Voting = int64(voting.(float64))
256254
vsp.Voted = int64(voted.(float64))
257-
vsp.Revoked = int64(revoked.(float64))
255+
vsp.Expired = int64(expired.(float64))
256+
vsp.Missed = int64(missed.(float64))
258257
vsp.VspdVersion = version.(string)
259258
vsp.BlockHeight = uint64(blockheight.(float64))
260259
vsp.EstimatedNetworkProportion = networkproportion.(float64)
261260

262-
// Expired and Missed were introduced in vspd 1.3.0 so they will be absent
263-
// from the responses received from older versions. When every VSP is
264-
// updated to 1.3.0+ these fields can be treated like every other required
265-
// field.
266-
if hasExpired {
267-
vsp.Expired = int64(expired.(float64))
268-
}
269-
270-
if hasMissed {
271-
vsp.Missed = int64(missed.(float64))
272-
}
273-
274261
vsp.LastUpdated = time.Now().Unix()
275262

276263
service.Mutex.Lock()

0 commit comments

Comments
 (0)