multi: Remove unnecessary convs found by unconvert.
This removes all unnecessary typecast conversions as found by the unconvert linter.
This commit is contained in:
parent
aa53c14a19
commit
af524fb3e7
13 changed files with 29 additions and 30 deletions
|
@ -246,12 +246,12 @@ func GroupKey(na *wire.NetAddress) string {
|
||||||
}
|
}
|
||||||
if IsRFC6145(na) || IsRFC6052(na) {
|
if IsRFC6145(na) || IsRFC6052(na) {
|
||||||
// last four bytes are the ip address
|
// last four bytes are the ip address
|
||||||
ip := net.IP(na.IP[12:16])
|
ip := na.IP[12:16]
|
||||||
return ip.Mask(net.CIDRMask(16, 32)).String()
|
return ip.Mask(net.CIDRMask(16, 32)).String()
|
||||||
}
|
}
|
||||||
|
|
||||||
if IsRFC3964(na) {
|
if IsRFC3964(na) {
|
||||||
ip := net.IP(na.IP[2:6])
|
ip := na.IP[2:6]
|
||||||
return ip.Mask(net.CIDRMask(16, 32)).String()
|
return ip.Mask(net.CIDRMask(16, 32)).String()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -843,7 +843,8 @@ func LockTimeToSequence(isSeconds bool, locktime uint32) uint32 {
|
||||||
// shift the locktime over by 9 since the time granularity is in
|
// shift the locktime over by 9 since the time granularity is in
|
||||||
// 512-second intervals (2^9). This results in a max lock-time of
|
// 512-second intervals (2^9). This results in a max lock-time of
|
||||||
// 33,553,920 seconds, or 1.1 years.
|
// 33,553,920 seconds, or 1.1 years.
|
||||||
return wire.SequenceLockTimeIsSeconds | uint32(locktime>>wire.SequenceLockTimeGranularity)
|
return wire.SequenceLockTimeIsSeconds |
|
||||||
|
locktime>>wire.SequenceLockTimeGranularity
|
||||||
}
|
}
|
||||||
|
|
||||||
// getReorganizeNodes finds the fork point between the main chain and the passed
|
// getReorganizeNodes finds the fork point between the main chain and the passed
|
||||||
|
|
|
@ -875,7 +875,7 @@ func CheckTransactionInputs(tx *btcutil.Tx, txHeight int32, utxoView *UtxoViewpo
|
||||||
// Ensure the transaction is not spending coins which have not
|
// Ensure the transaction is not spending coins which have not
|
||||||
// yet reached the required coinbase maturity.
|
// yet reached the required coinbase maturity.
|
||||||
if utxoEntry.IsCoinBase() {
|
if utxoEntry.IsCoinBase() {
|
||||||
originHeight := int32(utxoEntry.BlockHeight())
|
originHeight := utxoEntry.BlockHeight()
|
||||||
blocksSincePrev := txHeight - originHeight
|
blocksSincePrev := txHeight - originHeight
|
||||||
coinbaseMaturity := int32(chainParams.CoinbaseMaturity)
|
coinbaseMaturity := int32(chainParams.CoinbaseMaturity)
|
||||||
if blocksSincePrev < coinbaseMaturity {
|
if blocksSincePrev < coinbaseMaturity {
|
||||||
|
|
|
@ -572,7 +572,7 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) {
|
||||||
} else {
|
} else {
|
||||||
bmgrLog.Debugf("Extracted height of %v from "+
|
bmgrLog.Debugf("Extracted height of %v from "+
|
||||||
"orphan block", cbHeight)
|
"orphan block", cbHeight)
|
||||||
heightUpdate = int32(cbHeight)
|
heightUpdate = cbHeight
|
||||||
blkHashUpdate = blockHash
|
blkHashUpdate = blockHash
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -615,7 +615,7 @@ func (b *blockManager) handleBlockMsg(bmsg *blockMsg) {
|
||||||
if blkHashUpdate != nil && heightUpdate != 0 {
|
if blkHashUpdate != nil && heightUpdate != 0 {
|
||||||
bmsg.peer.UpdateLastBlockHeight(heightUpdate)
|
bmsg.peer.UpdateLastBlockHeight(heightUpdate)
|
||||||
if isOrphan || b.current() {
|
if isOrphan || b.current() {
|
||||||
go b.server.UpdatePeerHeights(blkHashUpdate, int32(heightUpdate), bmsg.peer)
|
go b.server.UpdatePeerHeights(blkHashUpdate, heightUpdate, bmsg.peer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,7 +882,7 @@ func (b *blockManager) handleInvMsg(imsg *invMsg) {
|
||||||
if lastBlock != -1 && b.current() {
|
if lastBlock != -1 && b.current() {
|
||||||
blkHeight, err := b.chain.BlockHeightByHash(&invVects[lastBlock].Hash)
|
blkHeight, err := b.chain.BlockHeightByHash(&invVects[lastBlock].Hash)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
imsg.peer.UpdateLastBlockHeight(int32(blkHeight))
|
imsg.peer.UpdateLastBlockHeight(blkHeight)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -562,7 +562,7 @@ func loadConfig() (*config, []string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't allow ban durations that are too short.
|
// Don't allow ban durations that are too short.
|
||||||
if cfg.BanDuration < time.Duration(time.Second) {
|
if cfg.BanDuration < time.Second {
|
||||||
str := "%s: The banduration option may not be less than 1s -- parsed [%v]"
|
str := "%s: The banduration option may not be less than 1s -- parsed [%v]"
|
||||||
err := fmt.Errorf(str, funcName, cfg.BanDuration)
|
err := fmt.Errorf(str, funcName, cfg.BanDuration)
|
||||||
fmt.Fprintln(os.Stderr, err)
|
fmt.Fprintln(os.Stderr, err)
|
||||||
|
@ -983,9 +983,9 @@ func createDefaultConfigFile(destinationPath string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.Contains(line, "rpcuser=") {
|
if strings.Contains(line, "rpcuser=") {
|
||||||
line = "rpcuser=" + string(generatedRPCUser) + "\n"
|
line = "rpcuser=" + generatedRPCUser + "\n"
|
||||||
} else if strings.Contains(line, "rpcpass=") {
|
} else if strings.Contains(line, "rpcpass=") {
|
||||||
line = "rpcpass=" + string(generatedRPCPass) + "\n"
|
line = "rpcpass=" + generatedRPCPass + "\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := dest.WriteString(line); err != nil {
|
if _, err := dest.WriteString(line); err != nil {
|
||||||
|
|
|
@ -760,7 +760,7 @@ func newBlockStore(basePath string, network wire.BitcoinNet) *blockStore {
|
||||||
writeCursor: &writeCursor{
|
writeCursor: &writeCursor{
|
||||||
curFile: &lockableFile{},
|
curFile: &lockableFile{},
|
||||||
curFileNum: uint32(fileNum),
|
curFileNum: uint32(fileNum),
|
||||||
curOffset: uint32(fileOff),
|
curOffset: fileOff,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
store.openFileFunc = store.openFile
|
store.openFileFunc = store.openFile
|
||||||
|
|
|
@ -454,7 +454,7 @@ func (p *Peer) UpdateLastBlockHeight(newHeight int32) {
|
||||||
p.statsMtx.Lock()
|
p.statsMtx.Lock()
|
||||||
log.Tracef("Updating last block height of peer %v from %v to %v",
|
log.Tracef("Updating last block height of peer %v from %v to %v",
|
||||||
p.addr, p.lastBlock, newHeight)
|
p.addr, p.lastBlock, newHeight)
|
||||||
p.lastBlock = int32(newHeight)
|
p.lastBlock = newHeight
|
||||||
p.statsMtx.Unlock()
|
p.statsMtx.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -805,7 +805,7 @@ func (p *Peer) localVersionMsg() (*wire.MsgVersion, error) {
|
||||||
sentNonces.Add(nonce)
|
sentNonces.Add(nonce)
|
||||||
|
|
||||||
// Version message.
|
// Version message.
|
||||||
msg := wire.NewMsgVersion(ourNA, theirNA, nonce, int32(blockNum))
|
msg := wire.NewMsgVersion(ourNA, theirNA, nonce, blockNum)
|
||||||
msg.AddUserAgent(p.cfg.UserAgentName, p.cfg.UserAgentVersion)
|
msg.AddUserAgent(p.cfg.UserAgentName, p.cfg.UserAgentVersion)
|
||||||
|
|
||||||
// XXX: bitcoind appears to always enable the full node services flag
|
// XXX: bitcoind appears to always enable the full node services flag
|
||||||
|
@ -2054,7 +2054,7 @@ func newPeerBase(origCfg *Config, inbound bool) *Peer {
|
||||||
// caller.
|
// caller.
|
||||||
cfg := *origCfg // Copy to avoid mutating caller.
|
cfg := *origCfg // Copy to avoid mutating caller.
|
||||||
if cfg.ProtocolVersion == 0 {
|
if cfg.ProtocolVersion == 0 {
|
||||||
cfg.ProtocolVersion = uint32(MaxProtocolVersion)
|
cfg.ProtocolVersion = MaxProtocolVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the chain parameters to testnet if the caller did not specify any.
|
// Set the chain parameters to testnet if the caller did not specify any.
|
||||||
|
|
|
@ -545,7 +545,7 @@ func handleCreateRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan
|
||||||
return nil, rpcDecodeHexError(input.Txid)
|
return nil, rpcDecodeHexError(input.Txid)
|
||||||
}
|
}
|
||||||
|
|
||||||
prevOut := wire.NewOutPoint(txHash, uint32(input.Vout))
|
prevOut := wire.NewOutPoint(txHash, input.Vout)
|
||||||
txIn := wire.NewTxIn(prevOut, []byte{})
|
txIn := wire.NewTxIn(prevOut, []byte{})
|
||||||
if c.LockTime != nil && *c.LockTime != 0 {
|
if c.LockTime != nil && *c.LockTime != 0 {
|
||||||
txIn.Sequence = wire.MaxTxInSequenceNum - 1
|
txIn.Sequence = wire.MaxTxInSequenceNum - 1
|
||||||
|
@ -1200,7 +1200,7 @@ func handleGetBlockHeader(s *rpcServer, cmd interface{}, closeChan <-chan struct
|
||||||
blockHeaderReply := btcjson.GetBlockHeaderVerboseResult{
|
blockHeaderReply := btcjson.GetBlockHeaderVerboseResult{
|
||||||
Hash: c.Hash,
|
Hash: c.Hash,
|
||||||
Confirmations: uint64(1 + best.Height - blockHeight),
|
Confirmations: uint64(1 + best.Height - blockHeight),
|
||||||
Height: int32(blockHeight),
|
Height: blockHeight,
|
||||||
Version: blockHeader.Version,
|
Version: blockHeader.Version,
|
||||||
MerkleRoot: blockHeader.MerkleRoot.String(),
|
MerkleRoot: blockHeader.MerkleRoot.String(),
|
||||||
NextHash: nextHashString,
|
NextHash: nextHashString,
|
||||||
|
@ -3647,12 +3647,11 @@ func handleVerifyMessage(s *rpcServer, cmd interface{}, closeChan <-chan struct{
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reconstruct the pubkey hash.
|
// Reconstruct the pubkey hash.
|
||||||
btcPK := (*btcec.PublicKey)(pk)
|
|
||||||
var serializedPK []byte
|
var serializedPK []byte
|
||||||
if wasCompressed {
|
if wasCompressed {
|
||||||
serializedPK = btcPK.SerializeCompressed()
|
serializedPK = pk.SerializeCompressed()
|
||||||
} else {
|
} else {
|
||||||
serializedPK = btcPK.SerializeUncompressed()
|
serializedPK = pk.SerializeUncompressed()
|
||||||
}
|
}
|
||||||
address, err := btcutil.NewAddressPubKey(serializedPK,
|
address, err := btcutil.NewAddressPubKey(serializedPK,
|
||||||
activeNetParams.Params)
|
activeNetParams.Params)
|
||||||
|
|
|
@ -448,7 +448,7 @@ func (m *memWallet) CreateTransaction(outputs []*wire.TxOut, feeRate btcutil.Amo
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to fund the transaction with spendable utxos.
|
// Attempt to fund the transaction with spendable utxos.
|
||||||
if err := m.fundTx(tx, outputAmt, btcutil.Amount(feeRate)); err != nil {
|
if err := m.fundTx(tx, outputAmt, feeRate); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ func New(activeNet *chaincfg.Params, handlers *btcrpcclient.NotificationHandlers
|
||||||
"of the supported chain networks")
|
"of the supported chain networks")
|
||||||
}
|
}
|
||||||
|
|
||||||
harnessID := strconv.Itoa(int(numTestInstances))
|
harnessID := strconv.Itoa(numTestInstances)
|
||||||
nodeTestData, err := ioutil.TempDir("", "rpctest-"+harnessID)
|
nodeTestData, err := ioutil.TempDir("", "rpctest-"+harnessID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
@ -420,8 +420,8 @@ func (*wsNotificationManager) notifyBlockConnected(clients map[chan struct{}]*ws
|
||||||
block *btcutil.Block) {
|
block *btcutil.Block) {
|
||||||
|
|
||||||
// Notify interested websocket clients about the connected block.
|
// Notify interested websocket clients about the connected block.
|
||||||
ntfn := btcjson.NewBlockConnectedNtfn(block.Hash().String(),
|
ntfn := btcjson.NewBlockConnectedNtfn(block.Hash().String(), block.Height(),
|
||||||
int32(block.Height()), block.MsgBlock().Header.Timestamp.Unix())
|
block.MsgBlock().Header.Timestamp.Unix())
|
||||||
marshalledJSON, err := btcjson.MarshalCmd(nil, ntfn)
|
marshalledJSON, err := btcjson.MarshalCmd(nil, ntfn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rpcsLog.Error("Failed to marshal block connected notification: "+
|
rpcsLog.Error("Failed to marshal block connected notification: "+
|
||||||
|
@ -445,7 +445,7 @@ func (*wsNotificationManager) notifyBlockDisconnected(clients map[chan struct{}]
|
||||||
|
|
||||||
// Notify interested websocket clients about the disconnected block.
|
// Notify interested websocket clients about the disconnected block.
|
||||||
ntfn := btcjson.NewBlockDisconnectedNtfn(block.Hash().String(),
|
ntfn := btcjson.NewBlockDisconnectedNtfn(block.Hash().String(),
|
||||||
int32(block.Height()), block.MsgBlock().Header.Timestamp.Unix())
|
block.Height(), block.MsgBlock().Header.Timestamp.Unix())
|
||||||
marshalledJSON, err := btcjson.MarshalCmd(nil, ntfn)
|
marshalledJSON, err := btcjson.MarshalCmd(nil, ntfn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rpcsLog.Error("Failed to marshal block disconnected "+
|
rpcsLog.Error("Failed to marshal block disconnected "+
|
||||||
|
@ -602,7 +602,7 @@ func blockDetails(block *btcutil.Block, txIndex int) *btcjson.BlockDetails {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
return &btcjson.BlockDetails{
|
return &btcjson.BlockDetails{
|
||||||
Height: int32(block.Height()),
|
Height: block.Height(),
|
||||||
Hash: block.Hash().String(),
|
Hash: block.Hash().String(),
|
||||||
Index: txIndex,
|
Index: txIndex,
|
||||||
Time: block.MsgBlock().Header.Timestamp.Unix(),
|
Time: block.MsgBlock().Header.Timestamp.Unix(),
|
||||||
|
@ -2026,8 +2026,7 @@ fetchRange:
|
||||||
}
|
}
|
||||||
|
|
||||||
n := btcjson.NewRescanProgressNtfn(hashList[i].String(),
|
n := btcjson.NewRescanProgressNtfn(hashList[i].String(),
|
||||||
int32(blk.Height()),
|
blk.Height(), blk.MsgBlock().Header.Timestamp.Unix())
|
||||||
blk.MsgBlock().Header.Timestamp.Unix())
|
|
||||||
mn, err := btcjson.MarshalCmd(nil, n)
|
mn, err := btcjson.MarshalCmd(nil, n)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rpcsLog.Errorf("Failed to marshal rescan "+
|
rpcsLog.Errorf("Failed to marshal rescan "+
|
||||||
|
|
|
@ -135,7 +135,7 @@ func (b *ScriptBuilder) addData(data []byte) *ScriptBuilder {
|
||||||
b.script = append(b.script, OP_0)
|
b.script = append(b.script, OP_0)
|
||||||
return b
|
return b
|
||||||
} else if dataLen == 1 && data[0] <= 16 {
|
} else if dataLen == 1 && data[0] <= 16 {
|
||||||
b.script = append(b.script, byte((OP_1-1)+data[0]))
|
b.script = append(b.script, (OP_1-1)+data[0])
|
||||||
return b
|
return b
|
||||||
} else if dataLen == 1 && data[0] == 0x81 {
|
} else if dataLen == 1 && data[0] == 0x81 {
|
||||||
b.script = append(b.script, byte(OP_1NEGATE))
|
b.script = append(b.script, byte(OP_1NEGATE))
|
||||||
|
|
|
@ -165,7 +165,7 @@ func (alert *Alert) Serialize(w io.Writer, pver uint32) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i := 0; i < int(count); i++ {
|
for i := 0; i < count; i++ {
|
||||||
err = writeElement(w, alert.SetCancel[i])
|
err = writeElement(w, alert.SetCancel[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -187,7 +187,7 @@ func (alert *Alert) Serialize(w io.Writer, pver uint32) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for i := 0; i < int(count); i++ {
|
for i := 0; i < count; i++ {
|
||||||
err = WriteVarString(w, pver, alert.SetSubVer[i])
|
err = WriteVarString(w, pver, alert.SetSubVer[i])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Add table
Reference in a new issue