From 393a95c079b14ce3e043bbd66bc0ccbe03dae42f Mon Sep 17 00:00:00 2001 From: David Hill Date: Thu, 8 Feb 2018 11:31:56 -0500 Subject: [PATCH] multi: fix some maligned linter warnings --- blockchain/chainio.go | 12 ++++----- blockchain/stake/internal/ticketdb/chainio.go | 2 +- blockchain/utxoviewpoint.go | 4 +-- connmgr/connmanager.go | 6 ++--- database/ffldb/blockio.go | 10 +++---- hdkeychain/extendedkey.go | 4 +-- rpctest/memwallet.go | 2 +- txscript/engine.go | 27 ++++++++++--------- 8 files changed, 34 insertions(+), 33 deletions(-) diff --git a/blockchain/chainio.go b/blockchain/chainio.go index da363b9d..286cd969 100644 --- a/blockchain/chainio.go +++ b/blockchain/chainio.go @@ -237,20 +237,20 @@ func ConvertUtxosToMinimalOutputs(entry *UtxoEntry) []*stake.MinimalOutput { // // The struct is aligned for memory efficiency. type spentTxOut struct { - pkScript []byte // The public key script for the output. - stakeExtra []byte // Extra information for the staking system. + pkScript []byte // The public key script for the output. + stakeExtra []byte // Extra information for the staking system. + amount int64 // The amount of the output. - txVersion uint16 // The version of creating tx. + txType stake.TxType // The stake type of the transaction. height uint32 // Height of the the block containing the tx. index uint32 // Index in the block of the transaction. scriptVersion uint16 // The version of the scripting language. - txType stake.TxType // The stake type of the transaction. + txVersion uint16 // The version of creating tx. txFullySpent bool // Whether or not the transaction is fully spent. isCoinBase bool // Whether creating tx is a coinbase. hasExpiry bool // The expiry of the creating tx. - - compressed bool // Whether or not the script is compressed. + compressed bool // Whether or not the script is compressed. } // spentTxOutSerializeSize returns the number of bytes it would take to diff --git a/blockchain/stake/internal/ticketdb/chainio.go b/blockchain/stake/internal/ticketdb/chainio.go index 02d37027..372da6ed 100644 --- a/blockchain/stake/internal/ticketdb/chainio.go +++ b/blockchain/stake/internal/ticketdb/chainio.go @@ -136,8 +136,8 @@ const databaseInfoSize = 8 // DatabaseInfo is the structure for a database. type DatabaseInfo struct { - Version uint32 Date time.Time + Version uint32 UpgradeStarted bool } diff --git a/blockchain/utxoviewpoint.go b/blockchain/utxoviewpoint.go index 4a04cbd6..605d26b3 100644 --- a/blockchain/utxoviewpoint.go +++ b/blockchain/utxoviewpoint.go @@ -92,10 +92,10 @@ type UtxoEntry struct { sparseOutputs map[uint32]*utxoOutput // Sparse map of unspent outputs. stakeExtra []byte // Extra data for the staking system. - txVersion uint16 // The tx version of this tx. + txType stake.TxType // The stake type of the transaction. height uint32 // Height of block containing tx. index uint32 // Index of containing tx in block. - txType stake.TxType // The stake type of the transaction. + txVersion uint16 // The tx version of this tx. isCoinBase bool // Whether entry is a coinbase tx. hasExpiry bool // Whether entry has an expiry. diff --git a/connmgr/connmanager.go b/connmgr/connmanager.go index 3194d805..1cf02b2d 100644 --- a/connmgr/connmanager.go +++ b/connmgr/connmanager.go @@ -58,13 +58,13 @@ type ConnReq struct { // The following variables must only be used atomically. id uint64 - Addr net.Addr - Permanent bool + Addr net.Addr conn net.Conn - state ConnState stateMtx sync.RWMutex retryCount uint32 + Permanent bool + state ConnState } // updateState updates the state of the connection request. diff --git a/database/ffldb/blockio.go b/database/ffldb/blockio.go index cafe3a46..3268149b 100644 --- a/database/ffldb/blockio.go +++ b/database/ffldb/blockio.go @@ -108,6 +108,11 @@ type writeCursor struct { // blockStore houses information used to handle reading and writing blocks (and // part of blocks) into flat files with support for multiple concurrent readers. type blockStore struct { + // maxBlockFileSize is the maximum size for each file used to store + // blocks. It is defined on the store so the whitebox tests can + // override the value. + maxBlockFileSize uint32 + // network is the specific network to use in the flat files for each // block. network wire.CurrencyNet @@ -115,11 +120,6 @@ type blockStore struct { // basePath is the base path used for the flat block files and metadata. basePath string - // maxBlockFileSize is the maximum size for each file used to store - // blocks. It is defined on the store so the whitebox tests can - // override the value. - maxBlockFileSize uint32 - // The following fields are related to the flat files which hold the // actual blocks. The number of open files is limited by maxOpenFiles. // diff --git a/hdkeychain/extendedkey.go b/hdkeychain/extendedkey.go index be7c40af..86b47f5c 100644 --- a/hdkeychain/extendedkey.go +++ b/hdkeychain/extendedkey.go @@ -102,10 +102,10 @@ type ExtendedKey struct { key []byte // This will be the pubkey for extended pub keys pubKey []byte // This will only be set for extended priv keys chainCode []byte - depth uint16 parentFP []byte - childNum uint32 version []byte + childNum uint32 + depth uint16 isPrivate bool } diff --git a/rpctest/memwallet.go b/rpctest/memwallet.go index 6e36f678..458d3d56 100644 --- a/rpctest/memwallet.go +++ b/rpctest/memwallet.go @@ -40,8 +40,8 @@ var ( type utxo struct { pkScript []byte value dcrutil.Amount - keyIndex uint32 maturityHeight int64 + keyIndex uint32 isLocked bool } diff --git a/txscript/engine.go b/txscript/engine.go index df4ff003..3d00f1db 100644 --- a/txscript/engine.go +++ b/txscript/engine.go @@ -95,21 +95,22 @@ var halfOrder = new(big.Int).Rsh(chainec.Secp256k1.GetN(), 1) // Engine is the virtual machine that executes scripts. type Engine struct { - version uint16 scripts [][]parsedOpcode - scriptIdx int - scriptOff int - lastCodeSep int - dstack stack // data stack - astack stack // alt stack - tx wire.MsgTx - txIdx int - condStack []int - numOps int - flags ScriptFlags - sigCache *SigCache - bip16 bool // treat execution as pay-to-script-hash savedFirstStack [][]byte // stack from first script for bip16 scripts + sigCache *SigCache + + scriptIdx int + scriptOff int + lastCodeSep int + dstack stack // data stack + astack stack // alt stack + tx wire.MsgTx + txIdx int + condStack []int + numOps int + flags ScriptFlags + version uint16 + bip16 bool // treat execution as pay-to-script-hash } // hasFlag returns whether the script engine instance has the passed flag set.