Fix admin page load when no wallet clients connected.
This commit is contained in:
parent
aa790b28aa
commit
4bcfa80dc4
@ -90,17 +90,15 @@ func withDcrdClient(dcrd rpc.DcrdConnect) gin.HandlerFunc {
|
||||
}
|
||||
}
|
||||
|
||||
// withWalletClients middleware adds a voting wallet clients to the request
|
||||
// context for downstream handlers to make use of.
|
||||
// withWalletClients middleware attempts to add voting wallet clients to the
|
||||
// request context for downstream handlers to make use of. Downstream handlers
|
||||
// must handle the case where no wallet clients are connected.
|
||||
func withWalletClients(wallets rpc.WalletConnect) gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
clients, failedConnections := wallets.Clients(c, cfg.NetParams)
|
||||
if len(clients) == 0 {
|
||||
log.Error("Could not connect to any wallets")
|
||||
sendError(errInternalError, c)
|
||||
return
|
||||
}
|
||||
if len(failedConnections) > 0 {
|
||||
} else if len(failedConnections) > 0 {
|
||||
log.Errorf("Failed to connect to %d wallet(s), proceeding with only %d",
|
||||
len(failedConnections), len(clients))
|
||||
}
|
||||
|
||||
@ -17,6 +17,13 @@ func setVoteChoices(c *gin.Context) {
|
||||
knownTicket := c.MustGet("KnownTicket").(bool)
|
||||
walletClients := c.MustGet("WalletClients").([]*rpc.WalletRPC)
|
||||
|
||||
// If we cannot set the vote choices on at least one voting wallet right
|
||||
// now, don't update the database, just return an error.
|
||||
if len(walletClients) == 0 {
|
||||
sendError(errInternalError, c)
|
||||
return
|
||||
}
|
||||
|
||||
if !knownTicket {
|
||||
log.Warnf("%s: Unknown ticket (clientIP=%s)", funcName, c.ClientIP())
|
||||
sendError(errUnknownTicket, c)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user