From 4b3ccac3c01b282f4390203c3c0f628165a2b2c2 Mon Sep 17 00:00:00 2001 From: David Hill Date: Wed, 18 Sep 2024 08:58:36 -0400 Subject: [PATCH] multi: fix some linter issues --- internal/rpc/rpcserver/server.go | 2 +- p2p/peering.go | 2 +- spv/sync.go | 9 +++------ wallet/createtx.go | 6 +++--- wallet/sidechains_test.go | 2 +- wallet/txauthor/author.go | 2 +- wallet/udb/addressmanager_test.go | 2 +- wallet/udb/internal_test.go | 2 +- wallet/udb/txdb.go | 2 +- wallet/udb/txmined.go | 2 +- wallet/udb/upgrades.go | 2 +- wallet/wallet.go | 2 +- 12 files changed, 16 insertions(+), 19 deletions(-) diff --git a/internal/rpc/rpcserver/server.go b/internal/rpc/rpcserver/server.go index d66eb4fe6..97eaba546 100644 --- a/internal/rpc/rpcserver/server.go +++ b/internal/rpc/rpcserver/server.go @@ -624,7 +624,7 @@ func (s *walletServer) BirthBlock(ctx context.Context, req *pb.BirthBlockRequest if birthState != nil { errMsg = "birth block is pending..." } - return nil, status.Errorf(codes.NotFound, errMsg) + return nil, status.Errorf(codes.NotFound, "%s", errMsg) } return &pb.BirthBlockResponse{ diff --git a/p2p/peering.go b/p2p/peering.go index 13c116921..3231d4333 100644 --- a/p2p/peering.go +++ b/p2p/peering.go @@ -1876,7 +1876,7 @@ func (rp *RemotePeer) CFiltersV2(ctx context.Context, blockHashes []*chainhash.H if !stalled.Stop() { <-stalled.C } - stalled.Reset(stallTimeout - time.Now().Sub(req.t)) + stalled.Reset(stallTimeout - time.Since(req.t)) case m := <-req.c: var f *gcs.FilterV2 var err error diff --git a/spv/sync.go b/spv/sync.go index 705079e63..c626346c7 100644 --- a/spv/sync.go +++ b/spv/sync.go @@ -894,11 +894,8 @@ func (s *Syncer) checkTSpend(ctx context.Context, tx *wire.MsgTx) bool { // Verify that the signature is valid and corresponds to the // provided public key. err = s.verifyTSpendSignature(tx, signature, pubKey) - if err != nil { - return false - } - return true + return err == nil } // GetInitState requests the init state, then using the tspend hashes requests @@ -1138,8 +1135,8 @@ func (s *Syncer) handleMixInvs(ctx context.Context, rp *p2p.RemotePeer, hashes [ } // receiveHeaderAnnouncements receives all block announcements through pushed -// headers messages messages from peers and starts goroutines to handle the -// announced header. +// headers messages from peers and starts goroutines to handle the announced +// header. func (s *Syncer) receiveHeadersAnnouncements(ctx context.Context) error { for { rp, headers, err := s.lp.ReceiveHeadersAnnouncement(ctx) diff --git a/wallet/createtx.go b/wallet/createtx.go index 8c80ddd9e..fc62526a9 100644 --- a/wallet/createtx.go +++ b/wallet/createtx.go @@ -1764,7 +1764,7 @@ func (w *Wallet) findEligibleOutputs(dbtx walletdb.ReadTx, account uint32, minco } // Only include this output if it meets the required number of - // confirmations. Coinbase transactions must have have reached + // confirmations. Coinbase transactions must have reached // maturity before their outputs may be spent. if !confirmed(minconf, output.Height, currentHeight) { continue @@ -1853,13 +1853,13 @@ func (w *Wallet) findEligibleOutputsAmount(dbtx walletdb.ReadTx, account uint32, } // Only include this output if it meets the required number of - // confirmations. Coinbase transactions must have have reached + // confirmations. Coinbase transactions must have reached // maturity before their outputs may be spent. if !confirmed(minconf, output.Height, currentHeight) { return true } - // When a minumum amount is required, skip when it is less. + // When a minimum amount is required, skip when it is less. if minAmount != 0 && output.Amount < minAmount { return true } diff --git a/wallet/sidechains_test.go b/wallet/sidechains_test.go index 2a28ec367..82c03aea7 100644 --- a/wallet/sidechains_test.go +++ b/wallet/sidechains_test.go @@ -110,7 +110,7 @@ func TestPruneChainFromSRT(t *testing.T) { } // Prune chain0. chain1 and chain2 are new rooted trees and chain3 is a - // a tip in chain2. + // tip in chain2. // b1 -> c1 -> d1 -> e1 // b2 -> c2 -> d2 -> e2 // \-> d3 -> e3 diff --git a/wallet/txauthor/author.go b/wallet/txauthor/author.go index 3e1011361..fe062e3df 100644 --- a/wallet/txauthor/author.go +++ b/wallet/txauthor/author.go @@ -85,7 +85,7 @@ func sumOutputValues(outputs []*wire.TxOut) (totalOutput dcrutil.Amount) { // // If successful, the transaction, total input value spent, and all previous // output scripts are returned. If the input source was unable to provide -// enough input value to pay for every output any any necessary fees, an +// enough input value to pay for every output any necessary fees, an // InputSourceError is returned. func NewUnsignedTransaction(outputs []*wire.TxOut, relayFeePerKb dcrutil.Amount, fetchInputs InputSource, fetchChange ChangeSource, maxTxSize int) (*AuthoredTx, error) { diff --git a/wallet/udb/addressmanager_test.go b/wallet/udb/addressmanager_test.go index 813eddccc..5225ec43e 100644 --- a/wallet/udb/addressmanager_test.go +++ b/wallet/udb/addressmanager_test.go @@ -1029,7 +1029,7 @@ func testEncryptDecryptErrors(ctx context.Context, tc *testContext) { } } -// testEncryptDecrypt ensures that encrypting and decrypting data with the +// testEncryptDecrypt ensures that encrypting and decrypting data with // the various crypto key types works as expected. func testEncryptDecrypt(ctx context.Context, tc *testContext) { plainText := []byte("this is a plaintext") diff --git a/wallet/udb/internal_test.go b/wallet/udb/internal_test.go index 727d8c4c0..bbdc56125 100644 --- a/wallet/udb/internal_test.go +++ b/wallet/udb/internal_test.go @@ -4,7 +4,7 @@ // license that can be found in the LICENSE file. /* -This test file is part of the waddrmgr package rather than than the +This test file is part of the waddrmgr package rather than the waddrmgr_test package so it can bridge access to the internals to properly test cases which are either not possible or can't reliably be tested via the public interface. The functions are only exported while the tests are being run. diff --git a/wallet/udb/txdb.go b/wallet/udb/txdb.go index d7c24747f..926aa12c0 100644 --- a/wallet/udb/txdb.go +++ b/wallet/udb/txdb.go @@ -1395,7 +1395,7 @@ func extractRawUnminedTx(v []byte) []byte { // Unmined transactions which have been saved in an unpublished state are // recorded as such in the unpublished bucket keyed by the transaction hash. -// The value is is a single non-zero byte if the transaction is unpublished, or +// The value is a single non-zero byte if the transaction is unpublished, or // zero or missing from the bucket when published. func putUnpublished(ns walletdb.ReadWriteBucket, k []byte) error { diff --git a/wallet/udb/txmined.go b/wallet/udb/txmined.go index 7cc976db4..efaf23196 100644 --- a/wallet/udb/txmined.go +++ b/wallet/udb/txmined.go @@ -3291,7 +3291,7 @@ func (s *Store) MakeInputSource(dbtx walletdb.ReadTx, account uint32, minConf, } // Only include this output if it meets the required number of - // confirmations. Coinbase transactions must have have reached + // confirmations. Coinbase transactions must have reached // maturity before their outputs may be spent. txHeight := extractRawCreditHeight(cKey) if !confirmed(minConf, txHeight, syncHeight) { diff --git a/wallet/udb/upgrades.go b/wallet/udb/upgrades.go index b8aa65b42..5ae2d7cee 100644 --- a/wallet/udb/upgrades.go +++ b/wallet/udb/upgrades.go @@ -170,7 +170,7 @@ const ( tspendPolicyVersion = 19 // vspBucketVersion is the 20th version of the database. It adds a - // a top-level bucket for recording vsp ticket hashes as key and its + // top-level bucket for recording vsp ticket hashes as key and its // related fee txs hash. vspBucketVersion = 20 diff --git a/wallet/wallet.go b/wallet/wallet.go index 581148d61..c0eff9e76 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -4737,7 +4737,7 @@ func (w *Wallet) CreateVspPayment(ctx context.Context, tx *wire.MsgTx, fee dcrut if err != nil { return err } - return fmt.Errorf(sigErrStr) + return fmt.Errorf("%s", sigErrStr) } err = w.SetPublished(ctx, &feeHash, false)