vspd/internal/webapi/vspinfo.go
jholdstock ecf2baa193 Begin module dev cycles.
Upcoming changes constitute breaking public API changes to both the
client and types modules, therefore this bumps the version numbers of
both modules and adds local replacements to go.mod files such that the
new versions can be used before they are publicly tagged.
2024-05-29 11:02:50 +01:00

39 lines
1.2 KiB
Go

// Copyright (c) 2020-2024 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package webapi
import (
"time"
"github.com/decred/vspd/internal/version"
"github.com/decred/vspd/types/v3"
"github.com/gin-gonic/gin"
)
// vspInfo is the handler for "GET /api/v3/vspinfo".
func (w *WebAPI) vspInfo(c *gin.Context) {
cachedStats := c.MustGet(cacheKey).(cacheData)
w.sendJSONResponse(types.VspInfoResponse{
APIVersions: []int64{3},
Timestamp: time.Now().Unix(),
PubKey: w.signPubKey,
FeePercentage: w.cfg.VSPFee,
Network: w.cfg.Network.Name,
VspClosed: w.cfg.VspClosed,
VspClosedMsg: w.cfg.VspClosedMsg,
VspdVersion: version.String(),
Voting: cachedStats.Voting,
Voted: cachedStats.Voted,
TotalVotingWallets: cachedStats.TotalVotingWallets,
VotingWalletsOnline: cachedStats.VotingWalletsOnline,
Revoked: cachedStats.Expired + cachedStats.Missed,
Expired: cachedStats.Expired,
Missed: cachedStats.Missed,
BlockHeight: cachedStats.BlockHeight,
NetworkProportion: cachedStats.NetworkProportion,
}, c)
}