Move feeAddressExpiration into webapi package.
This commit is contained in:
parent
443db9a7b9
commit
0318eded95
6
main.go
6
main.go
@ -6,7 +6,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/decred/vspd/background"
|
||||
"github.com/decred/vspd/database"
|
||||
@ -14,10 +13,6 @@ import (
|
||||
"github.com/decred/vspd/webapi"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultFeeAddressExpiration = 1 * time.Hour
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Create a context that is cancelled when a shutdown request is received
|
||||
// through an interrupt signal.
|
||||
@ -91,7 +86,6 @@ func run(ctx context.Context) error {
|
||||
apiCfg := webapi.Config{
|
||||
VSPFee: cfg.VSPFee,
|
||||
NetParams: cfg.netParams.Params,
|
||||
FeeAddressExpiration: defaultFeeAddressExpiration,
|
||||
SupportEmail: cfg.SupportEmail,
|
||||
VspClosed: cfg.VspClosed,
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ func feeAddress(c *gin.Context) {
|
||||
sendErrorResponse("fee error", http.StatusInternalServerError, c)
|
||||
return
|
||||
}
|
||||
ticket.FeeExpiration = now.Add(cfg.FeeAddressExpiration).Unix()
|
||||
ticket.FeeExpiration = now.Add(feeAddressExpiration).Unix()
|
||||
ticket.FeeAmount = newFee.ToCoin()
|
||||
|
||||
err = db.UpdateTicket(ticket)
|
||||
@ -162,7 +162,7 @@ func feeAddress(c *gin.Context) {
|
||||
}
|
||||
|
||||
now := time.Now()
|
||||
expire := now.Add(cfg.FeeAddressExpiration).Unix()
|
||||
expire := now.Add(feeAddressExpiration).Unix()
|
||||
|
||||
confirmed := rawTicket.Confirmations >= requiredConfs
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@ type Config struct {
|
||||
VSPFee float64
|
||||
NetParams *chaincfg.Params
|
||||
FeeAccountName string
|
||||
FeeAddressExpiration time.Duration
|
||||
SupportEmail string
|
||||
VspClosed bool
|
||||
}
|
||||
@ -33,6 +32,9 @@ const (
|
||||
// requiredConfs is the number of confirmations required to consider a
|
||||
// ticket purchase or a fee transaction to be final.
|
||||
requiredConfs = 6
|
||||
// feeAddressExpiration is the length of time a fee returned by /feeaddress
|
||||
// remains valid. After this time, a new fee must be requested.
|
||||
feeAddressExpiration = 1 * time.Hour
|
||||
)
|
||||
|
||||
var cfg Config
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user