Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeBoy committed Jun 24, 2024
2 parents ede9ed3 + bc06c86 commit 328c750
Show file tree
Hide file tree
Showing 83 changed files with 262 additions and 226 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ jobs:
${{ runner.os }}-go-
- name: Install linter
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v4
with:
version: v1.54
version: v1.59.1
skip-pkg-cache: true
args: --out-format=colored-line-number --timeout=10m

- name: Install dependencies
if: steps.cache.outputs.cache-hit != 'true'
Expand Down
15 changes: 13 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
run:
deadline: 10m
skip-dirs:

issues:
exclude-dirs:
# foreign languages give false positives for misspell
- ui/values/localizable

output:
format: github-actions,colored-line-number
formats: github-actions,colored-line-number

linters:
disable-all: true
Expand All @@ -18,3 +20,12 @@ linters:
- revive
- goimports
- unparam
- errcheck

linters-settings:
errcheck:
# Individual function to be ignored one per line.
# see https://github.com/kisielk/errcheck#excluding-functions for details
exclude-functions:
- (net/http.ResponseWriter).Write
- (*github.com/jrick/logrotate/rotator.Rotator).Write
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ require (
github.com/dgraph-io/badger v1.6.2
github.com/gen2brain/beeep v0.0.0-20220402123239-6a3042f4b71a
github.com/gomarkdown/markdown v0.0.0-20230922105210-14b16010c2ee
github.com/gorilla/websocket v1.5.0
github.com/jessevdk/go-flags v1.5.0
github.com/jrick/logrotate v1.0.0
github.com/kevinburke/nacl v0.0.0-20190829012316-f3ed23dbd7f8
Expand Down Expand Up @@ -149,6 +148,7 @@ require (
github.com/google/trillian v1.4.1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/schema v1.1.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/h2non/go-is-svg v0.0.0-20160927212452-35e8c4b0612c // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions libwallet/assets/btc/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func (asset *Asset) rescanFinished(height int32) {
// Update the assets birthday from genesis block to a date closer
// to when the privatekey was first used.
asset.updateAssetBirthday()
asset.MarkWalletAsDiscoveredAccounts()
_ = asset.MarkWalletAsDiscoveredAccounts()
}

asset.syncData.mu.Lock()
Expand Down Expand Up @@ -592,7 +592,7 @@ func (asset *Asset) reloadChainService() error {
asset.CancelSync()
}

asset.chainClient.CS.Stop()
_ = asset.chainClient.CS.Stop()
chainService, err := asset.loadChainService()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion libwallet/assets/dcr/account_mixer.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (asset *Asset) readCSPPConfig() *CSPPConfig {
csppTLSConfig.RootCAs = pool

dailer := new(net.Dialer)
dialCSPPServer = func(ctx context.Context, network, addr string) (net.Conn, error) {
dialCSPPServer = func(_ context.Context, network, addr string) (net.Conn, error) {
conn, err := dailer.DialContext(context.Background(), network, addr)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions libwallet/assets/dcr/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,12 @@ func (asset *Asset) SyncInactiveForPeriod(totalInactiveSeconds int64) {

func (asset *Asset) SetSpecificPeer(addresses string) {
asset.SaveUserConfigValue(sharedW.SpvPersistentPeerAddressesConfigKey, addresses)
asset.RestartSpvSync()
_ = asset.RestartSpvSync()
}

func (asset *Asset) RemovePeers() {
asset.SaveUserConfigValue(sharedW.SpvPersistentPeerAddressesConfigKey, "")
asset.RestartSpvSync()
_ = asset.RestartSpvSync()
}

func (asset *Asset) SpvSync() error {
Expand Down
4 changes: 2 additions & 2 deletions libwallet/assets/dcr/syncnotification.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (

func (asset *Asset) spvSyncNotificationCallbacks() *spv.Notifications {
return &spv.Notifications{
PeerConnected: func(peerCount int32, addr string) {
PeerConnected: func(peerCount int32, _ string) {
asset.handlePeerCountUpdate(peerCount)
},
PeerDisconnected: func(peerCount int32, addr string) {
PeerDisconnected: func(peerCount int32, _ string) {
asset.handlePeerCountUpdate(peerCount)
},
Synced: asset.syncedWallet,
Expand Down
2 changes: 1 addition & 1 deletion libwallet/assets/dcr/txparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ func (asset *Asset) decodeTransactionWithTxSummary(txSummary *w.TransactionSumma

// update ticket with spender hash
ticketPurchaseTx.TicketSpender = decodedTx.Hash
asset.GetWalletDataDb().SaveOrUpdate(&sharedW.Transaction{}, ticketPurchaseTx)
_, _ = asset.GetWalletDataDb().SaveOrUpdate(&sharedW.Transaction{}, ticketPurchaseTx)
}

return decodedTx, nil
Expand Down
2 changes: 1 addition & 1 deletion libwallet/assets/dcr/vsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ type vspDbData struct {

func (asset *Asset) getVSPDBData() *vspDbData {
vspDbData := new(vspDbData)
asset.ReadUserConfigValue(sharedW.KnownVSPsConfigKey, vspDbData)
_ = asset.ReadUserConfigValue(sharedW.KnownVSPsConfigKey, vspDbData)
return vspDbData
}

Expand Down
4 changes: 2 additions & 2 deletions libwallet/assets/ltc/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ func (asset *Asset) rescanFinished(height int32) {
// Update the assets birthday from genesis block to a date closer
// to when the privatekey was first used.
asset.updateAssetBirthday()
asset.MarkWalletAsDiscoveredAccounts()
_ = asset.MarkWalletAsDiscoveredAccounts()
}

asset.syncData.mu.Lock()
Expand Down Expand Up @@ -605,7 +605,7 @@ func (asset *Asset) reloadChainService() error {
asset.CancelSync()
}

asset.chainClient.CS.Stop()
_ = asset.chainClient.CS.Stop()
chainService, err := asset.loadChainService()
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion libwallet/assets/wallet/wallet_shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ func (wallet *Wallet) SetBirthday(birthday time.Time) {
wallet.mu.Lock()
wallet.Birthday = birthday
// Triggers db update with the new birthday time.
wallet.db.Save(wallet)
_ = wallet.db.Save(wallet)
wallet.mu.Unlock()
}

Expand Down
4 changes: 2 additions & 2 deletions libwallet/assets/wallet/wallet_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var InvalidBlock = &BlockInfo{
// a transaction needs to be consider as confirmed.
func (wallet *Wallet) RequiredConfirmations() int32 {
var spendUnconfirmed bool
wallet.ReadUserConfigValue(SpendUnconfirmedConfigKey, &spendUnconfirmed)
_ = wallet.ReadUserConfigValue(SpendUnconfirmedConfigKey, &spendUnconfirmed)
if spendUnconfirmed {
return 0
}
Expand Down Expand Up @@ -105,7 +105,7 @@ func (wallet *Wallet) batchDbTransaction(dbOp func(node storm.Node) error) (err
panicked := true
defer func() {
if panicked || err != nil {
dbTx.Rollback()
_ = dbTx.Rollback()
return
}

Expand Down
2 changes: 1 addition & 1 deletion libwallet/assets/wallet/walletdata/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (db *DB) SaveOrUpdate(emptyTxPointer, record interface{}) (overwritten bool
if timestamp > 0 {
overwritten = true
// delete old record before saving new (if it exists)
db.walletDataDB.DeleteStruct(emptyTxPointer)
_ = db.walletDataDB.DeleteStruct(emptyTxPointer)
}

if txlabel != "" {
Expand Down
2 changes: 1 addition & 1 deletion libwallet/badgerdb/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func newBucket(tx *badger.Txn, badgerKey []byte, dbTx *transaction) (*Bucket, er
return nil, convertErr(err)
}
if item.UserMeta() != metaBucket {
errors.E(errors.Invalid, "key is not associated with a bucket")
return nil, errors.E(errors.Invalid, "key is not associated with a bucket")
}
return &Bucket{txn: tx, prefix: prefix, dbTransaction: dbTx}, nil
}
Expand Down
4 changes: 2 additions & 2 deletions libwallet/badgerdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func (tx *transaction) DeleteTopLevelBucket(key []byte) error {
return errors.E(errors.Invalid)
}

tx.badgerTx.Delete(item.Key()[:])
_ = tx.badgerTx.Delete(item.Key()[:])

it := tx.badgerTx.NewIterator(badger.DefaultIteratorOptions)
defer it.Close()
Expand All @@ -108,7 +108,7 @@ func (tx *transaction) DeleteTopLevelBucket(key []byte) error {
}
prefixLength := int(val[0])
if bytes.Equal(item.Key()[:prefixLength], key) {
tx.badgerTx.Delete(item.Key()[:])
_ = tx.badgerTx.Delete(item.Key()[:])
}
}
for i := range tx.buckets {
Expand Down
2 changes: 1 addition & 1 deletion libwallet/dex_wallets_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func prepareDexSupportForDCRWallet() {
// This function will be invoked when the DEX client needs to
// setup a dcr ExchangeWallet; it allows us to use an existing
// wallet instance for wallet operations instead of json-rpc.
var walletMaker = func(settings map[string]string, chainParams *dcrcfg.Params, logger dex.Logger) (dexDcr.Wallet, error) {
var walletMaker = func(settings map[string]string, chainParams *dcrcfg.Params, _ dex.Logger) (dexDcr.Wallet, error) {
walletIDStr := settings[dexc.WalletIDConfigKey]
walletID, err := strconv.Atoi(walletIDStr)
if err != nil || walletID < 0 {
Expand Down
22 changes: 11 additions & 11 deletions libwallet/ext/ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ var (
UnconfirmedBalance: 0,
UnconfirmedTxs: 0,
Txs: 17,
TxIds: []string{
TxIDs: []string{
"bd1bf8897a5c1a53f3e90c26fc908d03624f8bd5d21da49ba8fa80cb99bae84d",
"335fc62ec6ebd8d29cef8dc98478807327ad2f2bc58a4ca6fb8a73411a38788f",
"88b4e3b7162667d0d5aec2e78663342721413a6fea280062444ab8d9f13065ac",
Expand Down Expand Up @@ -249,7 +249,7 @@ var (
UnconfirmedBalance: 0,
UnconfirmedTxs: 0,
Txs: 35,
TxIds: []string{
TxIDs: []string{
"bd1bf8897a5c1a53f3e90c26fc908d03624f8bd5d21da49ba8fa80cb99bae84d",
"335fc62ec6ebd8d29cef8dc98478807327ad2f2bc58a4ca6fb8a73411a38788f",
"88b4e3b7162667d0d5aec2e78663342721413a6fea280062444ab8d9f13065ac",
Expand Down Expand Up @@ -288,7 +288,7 @@ func TestGetBestBlock(t *testing.T) {
}{
{
name: "best block",
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`681536`))
})),
Expand Down Expand Up @@ -319,7 +319,7 @@ func TestGetBestBlockTimeStamp(t *testing.T) {
}{
{
name: "bestblock timeStamp",
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"height":681649,"size":22216,"hash":"0000000000000000109256ba6dab7e921c4d7e98d00357f51bff3b2d28ef345e",
"diff":3046219499.387013,"sdiff":227.59014758,"time":1659420872,"txlength":0,"ticket_pool":{"height":0,"size":41152,
Expand Down Expand Up @@ -354,7 +354,7 @@ func TestGetCurrentAgendaStatus(t *testing.T) {
}{
{
name: "current agenda status",
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"currentheight":681658,"startheight":681472,"endheight":689535,"hash":"00000000000000008a66428f2b98ab0ed1a220cfe23013acc393801d5e480b40",
"voteversion":9,"quorum":4032,"totalvotes":931,"agendas":[{"id":"reverttreasurypolicy","description":"Change maximum treasury expenditure policy as defined in DCP0007",
Expand Down Expand Up @@ -395,7 +395,7 @@ func TestGetAgendas(t *testing.T) {
}{
{
name: "agendas list",
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`[{"name":"reverttreasurypolicy","description":"Change maximum treasury expenditure policy as defined in DCP0007","status":"finished","votingStarted":0,"votingdone":649215,"activated":657280,"hardforked":0,"starttime":"2021-09-16T00:00:00Z","expiretime":"2023-09-16T00:00:00Z","voteversion":9,"mask":6},
{"name":"explicitverupgrades","description":"Enable explicit version upgrades as defined in DCP0008","status":"finished","votingStarted":0,"votingdone":649215,"activated":657280,"hardforked":0,"starttime":"2021-09-16T00:00:00Z","expiretime":"2023-09-16T00:00:00Z","voteversion":9,"mask":24},
Expand Down Expand Up @@ -431,7 +431,7 @@ func TestGetTreasuryBalance(t *testing.T) {
}{
{
name: "treasury balance",
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"height":681712,"maturity_height":681456,"balance":75919531830200,"output_count":129283,
"add_count":13,"added":61780107690000,"spend_count":5,"spent":779373012698,"tbase_count":129265,
Expand Down Expand Up @@ -467,7 +467,7 @@ func TestGetExchangeRate(t *testing.T) {
}{
{
name: "exchange rate",
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"btcIndex":"USD","dcrPrice":26.182965232480655,"btcPrice":22728.06395,
"exchanges":{
Expand Down Expand Up @@ -506,7 +506,7 @@ func TestGetTicketFeeRateSummary(t *testing.T) {
}{
{
name: "Ticket Fee rate summary",
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"height":681734,"time":1659448720,"number":0,"min":0,"max":0,"mean":0,"median":0,"stddev":0,"lowest_mineable":0}`))
})),
Expand Down Expand Up @@ -540,7 +540,7 @@ func TestGetTicketFeeRate(t *testing.T) {
}{
{
name: "Ticket Fee rate",
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"height":681741,"time":1659449708,"length":0,"total":0,"top_fees":[]}`))
})),
Expand Down Expand Up @@ -574,7 +574,7 @@ func TestGetAddress(t *testing.T) {
}{
{
name: "address state",
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
server: httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusOK)
w.Write([]byte(`{"page":1,"totalPages":1,"itemsOnPage":1000,"address":"DsTxPUVFxXeNgu5fzozr4mTR4tqqMaKcvpY","balance":"0",
"totalReceived":"95645588","totalSent":"95645588","unconfirmedBalance":"0","unconfirmedTxs":0,"txs":17,
Expand Down
4 changes: 2 additions & 2 deletions libwallet/ext/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type (
UnconfirmedBalance int64 `json:"unconfirmedBalance,string"`
UnconfirmedTxs int64 `json:"unconfirmedTxs"`
Txs int32 `json:"txs"`
TxIds []string `json:"txids"`
TxIDs []string `json:"txids"`
}

// XpubAddress models data about a specific xpub token.
Expand All @@ -100,7 +100,7 @@ type (
UnconfirmedBalance int64 `json:"unconfirmedBalance,string"`
UnconfirmedTxs int64 `json:"unconfirmedTxs"`
Txs int32 `json:"txs"`
TxIds []string `json:"txids"`
TxIDs []string `json:"txids"`
UsedTokens int32 `json:"usedTokens"`
XpubAddress []XpubAddress `json:"tokens"`
}
Expand Down
4 changes: 2 additions & 2 deletions libwallet/instantswap/instantswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (instantSwap *InstantSwap) saveOrOverwriteOrder(order *Order) error {

if oldOrder.UUID != "" {
// delete old record before saving new (if it exists)
instantSwap.db.DeleteStruct(oldOrder)
_ = instantSwap.db.DeleteStruct(oldOrder)
}

return instantSwap.db.Save(order)
Expand Down Expand Up @@ -240,7 +240,7 @@ func (instantSwap *InstantSwap) CreateOrder(exchangeObject instantswap.IDExchang
ExtraID: res.ExtraID, // changenow.io requirement //changelly payinExtraId value
}

instantSwap.saveOrder(order)
_ = instantSwap.saveOrder(order)
instantSwap.publishOrderCreated(order)

return order, nil
Expand Down
2 changes: 1 addition & 1 deletion libwallet/internal/politeia/politeia.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (p *Politeia) saveOrOverwiteProposal(proposal *Proposal) error {

if oldProposal.Token != "" {
// delete old record before saving new (if it exists)
p.db.DeleteStruct(oldProposal)
_ = p.db.DeleteStruct(oldProposal)
}

return p.db.Save(proposal)
Expand Down
2 changes: 1 addition & 1 deletion libwallet/internal/vsp/vsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (c *Client) FeePercentage(ctx context.Context) (float64, error) {
// any association with a VSP.
func (c *Client) ProcessUnprocessedTickets(ctx context.Context, policy Policy) {
var wg sync.WaitGroup
c.Wallet.ForUnspentUnexpiredTickets(ctx, func(hash *chainhash.Hash) error {
_ = c.Wallet.ForUnspentUnexpiredTickets(ctx, func(hash *chainhash.Hash) error {
// Skip tickets which have a fee tx already associated with
// them; they are already processed by some vsp.
_, err := c.Wallet.VSPFeeHashForTicket(ctx, hash)
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ func main() {
logDir := filepath.Join(cfg.LogDir, string(netType))
initLogRotator(logDir, cfg.MaxLogZips)
if cfg.DebugLevel == "" {
logger.SetLogLevels(utils.DefaultLogLevel)
_ = logger.SetLogLevels(utils.DefaultLogLevel)
} else {
logger.SetLogLevels(cfg.DebugLevel)
_ = logger.SetLogLevels(cfg.DebugLevel)
}

assetsManager, err := libwallet.NewAssetsManager(cfg.HomeDir, logDir, netType, cfg.DEXTestAddr)
Expand All @@ -78,7 +78,7 @@ func main() {
if cfg.DebugLevel != "" {
assetsManager.SetLogLevels(cfg.DebugLevel)
} else {
logger.SetLogLevels(assetsManager.GetLogLevels())
_ = logger.SetLogLevels(assetsManager.GetLogLevels())
}

return assetsManager, nil
Expand Down
Loading

0 comments on commit 328c750

Please sign in to comment.