Return string for failed rpc connections
This commit is contained in:
parent
7f969c6db5
commit
c5485a28ec
@ -159,9 +159,9 @@ func blockConnected() {
|
|||||||
log.Errorf("%s: Could not connect to any wallets", funcName)
|
log.Errorf("%s: Could not connect to any wallets", funcName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if failedConnections > 0 {
|
if len(failedConnections) > 0 {
|
||||||
log.Errorf("%s: Failed to connect to %d wallet(s), proceeding with only %d",
|
log.Errorf("%s: Failed to connect to %d wallet(s), proceeding with only %d",
|
||||||
funcName, failedConnections, len(walletClients))
|
funcName, len(failedConnections), len(walletClients))
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, ticket := range unconfirmedFees {
|
for _, ticket := range unconfirmedFees {
|
||||||
|
|||||||
@ -42,16 +42,16 @@ func (w *WalletConnect) Close() {
|
|||||||
// Clients loops over each wallet and tries to establish a connection. It
|
// Clients loops over each wallet and tries to establish a connection. It
|
||||||
// increments a count of failed connections if a connection cannot be
|
// increments a count of failed connections if a connection cannot be
|
||||||
// established, or if the wallet is misconfigured.
|
// established, or if the wallet is misconfigured.
|
||||||
func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params) ([]*WalletRPC, int) {
|
func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params) ([]*WalletRPC, []string) {
|
||||||
walletClients := make([]*WalletRPC, 0)
|
walletClients := make([]*WalletRPC, 0)
|
||||||
failedConnections := 0
|
failedConnections := make([]string, 0)
|
||||||
|
|
||||||
for _, connect := range []*client(*w) {
|
for _, connect := range []*client(*w) {
|
||||||
|
|
||||||
c, newConnection, err := connect.dial(ctx)
|
c, newConnection, err := connect.dial(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("dcrwallet connection error: %v", err)
|
log.Errorf("dcrwallet connection error: %v", err)
|
||||||
failedConnections++
|
failedConnections = append(failedConnections, connect.addr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,20 +67,20 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params)
|
|||||||
err = c.Call(ctx, "version", &verMap)
|
err = c.Call(ctx, "version", &verMap)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("version check on dcrwallet '%s' failed: %v", c.String(), err)
|
log.Errorf("version check on dcrwallet '%s' failed: %v", c.String(), err)
|
||||||
failedConnections++
|
failedConnections = append(failedConnections, connect.addr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
walletVersion, exists := verMap["dcrwalletjsonrpcapi"]
|
walletVersion, exists := verMap["dcrwalletjsonrpcapi"]
|
||||||
if !exists {
|
if !exists {
|
||||||
log.Errorf("version response on dcrwallet '%s' missing 'dcrwalletjsonrpcapi'",
|
log.Errorf("version response on dcrwallet '%s' missing 'dcrwalletjsonrpcapi'",
|
||||||
c.String())
|
c.String())
|
||||||
failedConnections++
|
failedConnections = append(failedConnections, connect.addr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if walletVersion.VersionString != requiredWalletVersion {
|
if walletVersion.VersionString != requiredWalletVersion {
|
||||||
log.Errorf("dcrwallet '%s' has wrong RPC version: got %s, expected %s",
|
log.Errorf("dcrwallet '%s' has wrong RPC version: got %s, expected %s",
|
||||||
c.String(), walletVersion.VersionString, requiredWalletVersion)
|
c.String(), walletVersion.VersionString, requiredWalletVersion)
|
||||||
failedConnections++
|
failedConnections = append(failedConnections, connect.addr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,12 +89,12 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params)
|
|||||||
err = c.Call(ctx, "getcurrentnet", &netID)
|
err = c.Call(ctx, "getcurrentnet", &netID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("getcurrentnet check on dcrwallet '%s' failed: %v", c.String(), err)
|
log.Errorf("getcurrentnet check on dcrwallet '%s' failed: %v", c.String(), err)
|
||||||
failedConnections++
|
failedConnections = append(failedConnections, connect.addr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if netID != netParams.Net {
|
if netID != netParams.Net {
|
||||||
log.Errorf("dcrwallet '%s' running on %s, expected %s", c.String(), netID, netParams.Net)
|
log.Errorf("dcrwallet '%s' running on %s, expected %s", c.String(), netID, netParams.Net)
|
||||||
failedConnections++
|
failedConnections = append(failedConnections, connect.addr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,7 +103,7 @@ func (w *WalletConnect) Clients(ctx context.Context, netParams *chaincfg.Params)
|
|||||||
walletInfo, err := walletRPC.WalletInfo()
|
walletInfo, err := walletRPC.WalletInfo()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("walletinfo check on dcrwallet '%s' failed: %v", c.String(), err)
|
log.Errorf("walletinfo check on dcrwallet '%s' failed: %v", c.String(), err)
|
||||||
failedConnections++
|
failedConnections = append(failedConnections, connect.addr)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -100,9 +100,9 @@ func withWalletClients(wallets rpc.WalletConnect) gin.HandlerFunc {
|
|||||||
sendError(errInternalError, c)
|
sendError(errInternalError, c)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if failedConnections > 0 {
|
if len(failedConnections) > 0 {
|
||||||
log.Errorf("Failed to connect to %d wallet(s), proceeding with only %d",
|
log.Errorf("Failed to connect to %d wallet(s), proceeding with only %d",
|
||||||
failedConnections, len(clients))
|
len(failedConnections), len(clients))
|
||||||
}
|
}
|
||||||
c.Set("WalletClients", clients)
|
c.Set("WalletClients", clients)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user