multi: Use go 1.22 language features.

This commit is contained in:
jholdstock 2024-10-16 09:06:46 +01:00 committed by Jamie Holdstock
parent cba9b0368b
commit 0d7b33d9bd
5 changed files with 7 additions and 7 deletions

View File

@ -107,7 +107,7 @@ func run() int {
log.Infof(" %s", tkt) log.Infof(" %s", tkt)
} }
for i := 0; i < len(tickets.Hashes); i++ { for i := range len(tickets.Hashes) {
// Stop if shutdown requested. // Stop if shutdown requested.
if ctx.Err() != nil { if ctx.Err() != nil {
return 0 return 0

View File

@ -1,4 +1,4 @@
// Copyright (c) 2020 The Decred developers // Copyright (c) 2020-2024 The Decred developers
// Use of this source code is governed by an ISC // Use of this source code is governed by an ISC
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
@ -39,7 +39,7 @@ func testVoteChangeRecords(t *testing.T) {
} }
// Insert some more records, giving us one greater than the limit. // Insert some more records, giving us one greater than the limit.
for i := 0; i < maxVoteChangeRecords; i++ { for range maxVoteChangeRecords {
err = db.SaveVoteChange(hash, record) err = db.SaveVoteChange(hash, record)
if err != nil { if err != nil {
t.Fatalf("error storing vote change record in database: %v", err) t.Fatalf("error storing vote change record in database: %v", err)

View File

@ -379,7 +379,7 @@ func LoadConfig() (*Config, error) {
// Load dcrwallet RPC certificate(s). // Load dcrwallet RPC certificate(s).
walletCerts := make([][]byte, numCert) walletCerts := make([][]byte, numCert)
for i := 0; i < numCert; i++ { for i := range numCert {
certs[i] = cleanAndExpandPath(certs[i]) certs[i] = cleanAndExpandPath(certs[i])
walletCerts[i], err = os.ReadFile(certs[i]) walletCerts[i], err = os.ReadFile(certs[i])
if err != nil { if err != nil {
@ -394,7 +394,7 @@ func LoadConfig() (*Config, error) {
} }
// Add default port for the active network if there is no port specified. // Add default port for the active network if there is no port specified.
for i := 0; i < numHost; i++ { for i := range numHost {
walletHosts[i] = normalizeAddress(walletHosts[i], cfg.network.WalletRPCServerPort) walletHosts[i] = normalizeAddress(walletHosts[i], cfg.network.WalletRPCServerPort)
} }

View File

@ -290,7 +290,7 @@ func (w *WebAPI) broadcastTicket(c *gin.Context) {
txBroadcast := func() bool { txBroadcast := func() bool {
// Wait for 1 second and try again, max 7 attempts. // Wait for 1 second and try again, max 7 attempts.
for i := 0; i < 7; i++ { for range 7 {
time.Sleep(1 * time.Second) time.Sleep(1 * time.Second)
err := dcrdClient.SendRawTransaction(request.ParentHex) err := dcrdClient.SendRawTransaction(request.ParentHex)
if err == nil { if err == nil {

View File

@ -34,7 +34,7 @@ type WalletConnect struct {
func SetupWallet(user, pass, addrs []string, cert [][]byte, params *chaincfg.Params, log slog.Logger) WalletConnect { func SetupWallet(user, pass, addrs []string, cert [][]byte, params *chaincfg.Params, log slog.Logger) WalletConnect {
clients := make([]*client, len(addrs)) clients := make([]*client, len(addrs))
for i := 0; i < len(addrs); i++ { for i := range len(addrs) {
clients[i] = setup(user[i], pass[i], addrs[i], cert[i], log) clients[i] = setup(user[i], pass[i], addrs[i], cert[i], log)
} }