Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi: clean up some linter warnings #2431

Merged
merged 3 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/rpc/rpcserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion p2p/peering.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions spv/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions wallet/createtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 3 additions & 0 deletions wallet/rescan.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ func (w *Wallet) rescan(ctx context.Context, n NetworkBackend,
err = walletdb.Update(ctx, w.db, func(dbtx walletdb.ReadWriteTx) error {
return w.txStore.UpdateProcessedTxsBlockMarker(dbtx, &rescanBlocks[len(rescanBlocks)-1])
})
if err != nil {
return err
}
if p != nil {
p <- RescanProgress{ScannedThrough: through}
}
Expand Down
2 changes: 1 addition & 1 deletion wallet/sidechains_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion wallet/txauthor/author.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion wallet/udb/addressmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion wallet/udb/internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion wallet/udb/txdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 10 additions & 10 deletions wallet/udb/txmined.go
Original file line number Diff line number Diff line change
Expand Up @@ -2348,7 +2348,7 @@ func (s *Store) UnspentOutputCount(dbtx walletdb.ReadTx) int {

// randomUTXO returns a random key/value pair from the unspent bucket, ignoring
// any keys that match the skip function.
func (s *Store) randomUTXO(dbtx walletdb.ReadTx, skip func(k, v []byte) bool) (k, v []byte, err error) {
func (s *Store) randomUTXO(dbtx walletdb.ReadTx, skip func(k, v []byte) bool) (k, v []byte) {
ns := dbtx.ReadBucket(wtxmgrBucketKey)

r := make([]byte, 33)
Expand Down Expand Up @@ -2378,7 +2378,7 @@ func (s *Store) randomUTXO(dbtx walletdb.ReadTx, skip func(k, v []byte) bool) (k
if len(keys) > 0 {
k, v = c.Seek(keys[rand.IntN(len(keys))])
c.Close()
return k, v, nil
return k, v
}

// Search the opposite direction from the random seek key.
Expand All @@ -2402,11 +2402,11 @@ func (s *Store) randomUTXO(dbtx walletdb.ReadTx, skip func(k, v []byte) bool) (k
if len(keys) > 0 {
k, v = c.Seek(keys[rand.IntN(len(keys))])
c.Close()
return k, v, err
return k, v
}

c.Close()
return nil, nil, nil
return nil, nil
}

// RandomUTXO returns a random unspent Credit, or nil if none matching are
Expand Down Expand Up @@ -2434,13 +2434,13 @@ func (s *Store) RandomUTXO(dbtx walletdb.ReadTx, minConf, syncHeight int32) (*Cr
}
return false
}
k, v, err := s.randomUTXO(dbtx, skip)
if k == nil || err != nil {
return nil, err
k, v := s.randomUTXO(dbtx, skip)
if k == nil {
return nil, nil
}
var op wire.OutPoint
var block Block
err = readCanonicalOutPoint(k, &op)
err := readCanonicalOutPoint(k, &op)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -3158,7 +3158,7 @@ func (s *Store) MakeInputSource(dbtx walletdb.ReadTx, account uint32, minConf,
var err error
if minConf != 0 && target != 0 && randTries < numUnspent/2 {
randTries++
k, v, err = s.randomUTXO(dbtx, skip)
k, v = s.randomUTXO(dbtx, skip)
if k != nil {
seen[string(k)] = struct{}{}
}
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion wallet/udb/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading