From 3cb961257cb348a3caf4267308cbe22cb7a3793f Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Mon, 23 May 2022 22:47:49 -0700 Subject: [PATCH] [lbry] ci: fixed various lint errors --- blockchain/checkpoints.go | 3 ++- blockchain/validate.go | 5 +---- btcec/genprecomps.go | 1 + btcec/gensecp256k1.go | 1 + btcec/precompute.go | 2 +- database/ffldb/db.go | 14 +++++++------- database/ffldb/dbcache.go | 6 +++--- database/ffldb/ldbtreapiter.go | 4 ++-- database/ffldb/whitebox_test.go | 4 ++-- limits/limits_unix.go | 1 + signalsigterm.go | 1 + upnp.go | 4 ++-- 12 files changed, 24 insertions(+), 22 deletions(-) diff --git a/blockchain/checkpoints.go b/blockchain/checkpoints.go index a82d70dd..e9b2d5a2 100644 --- a/blockchain/checkpoints.go +++ b/blockchain/checkpoints.go @@ -172,7 +172,8 @@ func (b *BlockChain) findPreviousCheckpoint() (*blockNode, error) { func isNonstandardTransaction(tx *btcutil.Tx) bool { // Check all of the output public key scripts for non-standard scripts. for _, txOut := range tx.MsgTx().TxOut { - scriptClass := txscript.GetScriptClass(txOut.PkScript) + stripped := txscript.StripClaimScriptPrefix(txOut.PkScript) + scriptClass := txscript.GetScriptClass(stripped) if scriptClass == txscript.NonStandardTy { return true } diff --git a/blockchain/validate.go b/blockchain/validate.go index 19183aa9..85946611 100644 --- a/blockchain/validate.go +++ b/blockchain/validate.go @@ -224,10 +224,7 @@ func withinLevelBounds(reduction int64, lv int64) bool { return false } reduction++ - if ((reduction*reduction + reduction) >> 1) <= lv { - return false - } - return true + return ((reduction*reduction + reduction) >> 1) > lv } // CheckTransactionSanity performs some preliminary checks on a transaction to diff --git a/btcec/genprecomps.go b/btcec/genprecomps.go index f09ab311..ea40ceac 100644 --- a/btcec/genprecomps.go +++ b/btcec/genprecomps.go @@ -5,6 +5,7 @@ // This file is ignored during the regular build due to the following build tag. // It is called by go generate and used to automatically generate pre-computed // tables used to accelerate operations. +//go:build ignore // +build ignore package main diff --git a/btcec/gensecp256k1.go b/btcec/gensecp256k1.go index 1928702d..e079f553 100644 --- a/btcec/gensecp256k1.go +++ b/btcec/gensecp256k1.go @@ -4,6 +4,7 @@ // This file is ignored during the regular build due to the following build tag. // This build tag is set during go generate. +//go:build gensecp256k1 // +build gensecp256k1 package btcec diff --git a/btcec/precompute.go b/btcec/precompute.go index 034cd553..3d2eedbb 100644 --- a/btcec/precompute.go +++ b/btcec/precompute.go @@ -12,7 +12,7 @@ import ( "strings" ) -//go:generate go run -tags gensecp256k1 genprecomps.go +//go:rm -f gensecp256k1.go; generate go run -tags gensecp256k1 genprecomps.go // loadS256BytePoints decompresses and deserializes the pre-computed byte points // used to accelerate scalar base multiplication for the secp256k1 curve. This diff --git a/database/ffldb/db.go b/database/ffldb/db.go index ee6d55f0..843ef6bb 100644 --- a/database/ffldb/db.go +++ b/database/ffldb/db.go @@ -14,18 +14,18 @@ import ( "sort" "sync" - "github.com/btcsuite/goleveldb/leveldb" - "github.com/btcsuite/goleveldb/leveldb/comparer" - ldberrors "github.com/btcsuite/goleveldb/leveldb/errors" - "github.com/btcsuite/goleveldb/leveldb/filter" - "github.com/btcsuite/goleveldb/leveldb/iterator" - "github.com/btcsuite/goleveldb/leveldb/opt" - "github.com/btcsuite/goleveldb/leveldb/util" "github.com/lbryio/lbcd/chaincfg/chainhash" "github.com/lbryio/lbcd/database" "github.com/lbryio/lbcd/database/internal/treap" "github.com/lbryio/lbcd/wire" btcutil "github.com/lbryio/lbcutil" + "github.com/syndtr/goleveldb/leveldb" + "github.com/syndtr/goleveldb/leveldb/comparer" + ldberrors "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/filter" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/util" ) const ( diff --git a/database/ffldb/dbcache.go b/database/ffldb/dbcache.go index 1bc21a35..eff239c6 100644 --- a/database/ffldb/dbcache.go +++ b/database/ffldb/dbcache.go @@ -10,10 +10,10 @@ import ( "sync" "time" - "github.com/btcsuite/goleveldb/leveldb" - "github.com/btcsuite/goleveldb/leveldb/iterator" - "github.com/btcsuite/goleveldb/leveldb/util" "github.com/lbryio/lbcd/database/internal/treap" + "github.com/syndtr/goleveldb/leveldb" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/util" ) const ( diff --git a/database/ffldb/ldbtreapiter.go b/database/ffldb/ldbtreapiter.go index 0a552633..2073abbe 100644 --- a/database/ffldb/ldbtreapiter.go +++ b/database/ffldb/ldbtreapiter.go @@ -5,9 +5,9 @@ package ffldb import ( - "github.com/btcsuite/goleveldb/leveldb/iterator" - "github.com/btcsuite/goleveldb/leveldb/util" "github.com/lbryio/lbcd/database/internal/treap" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/util" ) // ldbTreapIter wraps a treap iterator to provide the additional functionality diff --git a/database/ffldb/whitebox_test.go b/database/ffldb/whitebox_test.go index 15c83cec..31a8ab34 100644 --- a/database/ffldb/whitebox_test.go +++ b/database/ffldb/whitebox_test.go @@ -17,11 +17,11 @@ import ( "path/filepath" "testing" - "github.com/btcsuite/goleveldb/leveldb" - ldberrors "github.com/btcsuite/goleveldb/leveldb/errors" "github.com/lbryio/lbcd/database" "github.com/lbryio/lbcd/wire" btcutil "github.com/lbryio/lbcutil" + "github.com/syndtr/goleveldb/leveldb" + ldberrors "github.com/syndtr/goleveldb/leveldb/errors" ) var ( diff --git a/limits/limits_unix.go b/limits/limits_unix.go index e55a1c28..f8511458 100644 --- a/limits/limits_unix.go +++ b/limits/limits_unix.go @@ -2,6 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. +//go:build !windows && !plan9 // +build !windows,!plan9 package limits diff --git a/signalsigterm.go b/signalsigterm.go index 83165501..63bdb9c0 100644 --- a/signalsigterm.go +++ b/signalsigterm.go @@ -2,6 +2,7 @@ // Use of this source code is governed by an ISC // license that can be found in the LICENSE file. +//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris // +build darwin dragonfly freebsd linux netbsd openbsd solaris package main diff --git a/upnp.go b/upnp.go index 402924f5..d07d5ce9 100644 --- a/upnp.go +++ b/upnp.go @@ -136,7 +136,7 @@ func Discover() (nat NAT, err error) { return } err = errors.New("UPnP port discovery failed") - return + return nat, err } // service represents the Service type in an UPnP xml description. @@ -269,7 +269,7 @@ func getServiceURL(rootURL string) (url string, err error) { return } url = combineURL(rootURL, d.ControlURL) - return + return url, err } // combineURL appends subURL onto rootURL.