Skip to content

Commit

Permalink
Fix lint errors (#84)
Browse files Browse the repository at this point in the history
Remove unnecessary conversions, format import and remove unused struct(SyncErrorCode)
  • Loading branch information
beansgum authored and oluwandabira committed Jan 14, 2020
1 parent 39a5598 commit 310b336
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 16 deletions.
1 change: 1 addition & 0 deletions addresshelper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package addresshelper

import (
"fmt"

chaincfg "github.com/decred/dcrd/chaincfg/v2"
dcrutil "github.com/decred/dcrd/dcrutil/v2"
txscript "github.com/decred/dcrd/txscript/v2"
Expand Down
8 changes: 4 additions & 4 deletions badgerdb/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func (b *Bucket) Delete(key []byte) error {
return errors.E(errors.Invalid)
}

return convertErr((*Bucket)(b).delete(key))
return convertErr(b.delete(key))
}

func (b *Bucket) ReadCursor() walletdb.ReadCursor {
Expand Down Expand Up @@ -584,7 +584,7 @@ func (db *db) beginTx(writable bool) (*transaction, error) {
return nil, errors.E(errors.Invalid)
}

tx := (*badger.DB)(db.DB).NewTransaction(writable)
tx := db.DB.NewTransaction(writable)
tran := &transaction{badgerTx: tx, writable: writable, db: db}
return tran, nil
}
Expand Down Expand Up @@ -621,7 +621,7 @@ func (db *db) Close() error {

time.Sleep(2 * time.Second) // sleep for 2 seconds to ensure any db operation completes before proceeding

err := (*badger.DB)(db.DB).Close()
err := db.DB.Close()
if err != nil {
return convertErr(err)
}
Expand Down Expand Up @@ -675,5 +675,5 @@ func openDB(dbPath string, create bool) (walletdb.DB, error) {
}()
}

return (*db)(d), convertErr(err)
return d, convertErr(err)
}
11 changes: 2 additions & 9 deletions sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ type activeSyncData struct {
totalInactiveSeconds int64
}

type SyncErrorCode int32

const (
ErrorCodeUnexpectedError SyncErrorCode = iota
ErrorCodeDeadlineExceeded
)

const (
InvalidSyncStage = -1
HeadersFetchSyncStage = 0
Expand Down Expand Up @@ -237,9 +230,9 @@ func (mw *MultiWallet) SpvSync() error {
mw.notifySyncCanceled()
mw.syncData.syncCanceled <- true
} else if err == context.DeadlineExceeded {
mw.notifySyncError(ErrorCodeDeadlineExceeded, errors.E("SPV synchronization deadline exceeded: %v", err))
mw.notifySyncError(errors.E("SPV synchronization deadline exceeded: %v", err))
} else {
mw.notifySyncError(ErrorCodeUnexpectedError, err)
mw.notifySyncError(err)
}
}
}()
Expand Down
2 changes: 1 addition & 1 deletion syncnotification.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ func (mw *MultiWallet) estimateBlockHeadersCountAfter(lastHeaderTime int64) int3
return int32(math.Ceil(estimatedHeadersDifference))
}

func (mw *MultiWallet) notifySyncError(code SyncErrorCode, err error) {
func (mw *MultiWallet) notifySyncError(err error) {
mw.resetSyncData()

mw.syncData.mu.RLock()
Expand Down
2 changes: 1 addition & 1 deletion ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (wallet *Wallet) TicketPrice(ctx context.Context) (*TicketPriceResponse, er
_, tipHeight := wallet.internal.MainChainTip(ctx)
return &TicketPriceResponse{
TicketPrice: int64(ticketPrice),
Height: int32(tipHeight),
Height: tipHeight,
}, nil
}

Expand Down
3 changes: 2 additions & 1 deletion txparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package dcrlibwallet

import (
"fmt"

"github.com/decred/dcrd/chaincfg/chainhash"
w "github.com/decred/dcrwallet/wallet/v3"
)
Expand Down Expand Up @@ -29,7 +30,7 @@ func (wallet *Wallet) decodeTransactionWithTxSummary(txSummary *w.TransactionSum
Index: int32(input.Index),
AmountIn: int64(input.PreviousAmount),
WalletAccount: &WalletAccount{
AccountNumber: int32(accountNumber),
AccountNumber: accountNumber,
AccountName: wallet.AccountName(accountNumber),
},
}
Expand Down

0 comments on commit 310b336

Please sign in to comment.