* Remove static cfg values from GUI cache. Theres no need for these values to be copied into the cache when templates could simply access the config struct directly. This also changes the cache accessor so it returns a copy of the cache rather than a pointer, which removes a potential race. * Rename and move cache. Cache code was previous in `homepage.go`, but its used in multiple places and not just on the homepage. Its enough code to go into its own dedicated `cache.go`.
33 lines
918 B
Go
33 lines
918 B
Go
// Copyright (c) 2020-2021 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/version"
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
// vspInfo is the handler for "GET /api/v3/vspinfo".
|
|
func vspInfo(c *gin.Context) {
|
|
cachedStats := getCache()
|
|
sendJSONResponse(vspInfoResponse{
|
|
APIVersions: []int64{3},
|
|
Timestamp: time.Now().Unix(),
|
|
PubKey: signPubKey,
|
|
FeePercentage: cfg.VSPFee,
|
|
Network: cfg.NetParams.Name,
|
|
VspClosed: cfg.VspClosed,
|
|
VspClosedMsg: cfg.VspClosedMsg,
|
|
VspdVersion: version.String(),
|
|
Voting: cachedStats.Voting,
|
|
Voted: cachedStats.Voted,
|
|
Revoked: cachedStats.Revoked,
|
|
BlockHeight: cachedStats.BlockHeight,
|
|
NetworkProportion: cachedStats.NetworkProportion,
|
|
}, c)
|
|
}
|