From 143a6e01bb883f7c9c576d6c69111fef7581933a Mon Sep 17 00:00:00 2001 From: Andrey Samokhvalov Date: Thu, 23 Feb 2017 22:07:01 +0300 Subject: [PATCH] lnd: fix unconvert warnings --- chainntnfs/btcdnotify/btcd.go | 2 +- channeldb/channel.go | 6 +++--- channeldb/graph.go | 2 +- cmd/lncli/commands.go | 2 +- htlcswitch.go | 2 +- lnwire/lnwire.go | 8 ++++---- lnwire/signature.go | 4 ++-- peer.go | 2 +- rpcserver.go | 2 +- utxonursery.go | 6 +++--- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/chainntnfs/btcdnotify/btcd.go b/chainntnfs/btcdnotify/btcd.go index 3a56a193..a32fad92 100644 --- a/chainntnfs/btcdnotify/btcd.go +++ b/chainntnfs/btcdnotify/btcd.go @@ -560,7 +560,7 @@ func (b *BtcdNotifier) checkConfirmationTrigger(txSha *chainhash.Hash, // which notification(s) we should fire off with // each incoming block. confClient.initialConfirmHeight = uint32(newTip.blockHeight) - finalConfHeight := uint32(confClient.initialConfirmHeight + confClient.numConfirmations - 1) + finalConfHeight := confClient.initialConfirmHeight + confClient.numConfirmations - 1 heapEntry := &confEntry{ confClient, confDetails, diff --git a/channeldb/channel.go b/channeldb/channel.go index 7a5579fc..d2eec4ca 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -400,7 +400,7 @@ func (c *OpenChannel) UpdateCommitment(newCommitment *wire.MsgTx, c.OurCommitSig = newSig c.OurBalance = delta.LocalBalance c.TheirBalance = delta.RemoteBalance - c.NumUpdates = uint64(delta.UpdateNum) + c.NumUpdates = delta.UpdateNum c.Htlcs = delta.Htlcs // First we'll write out the current latest dynamic channel @@ -1137,13 +1137,13 @@ func putChanAmountsTransferred(openChanBucket *bolt.Bucket, channel *OpenChannel copy(keyPrefix[3:], b.Bytes()) copy(keyPrefix[:3], satSentPrefix) - byteOrder.PutUint64(scratch1, uint64(channel.TotalSatoshisSent)) + byteOrder.PutUint64(scratch1, channel.TotalSatoshisSent) if err := openChanBucket.Put(keyPrefix, scratch1); err != nil { return err } copy(keyPrefix[:3], satReceivedPrefix) - byteOrder.PutUint64(scratch2, uint64(channel.TotalSatoshisReceived)) + byteOrder.PutUint64(scratch2, channel.TotalSatoshisReceived) return openChanBucket.Put(keyPrefix, scratch2) } diff --git a/channeldb/graph.go b/channeldb/graph.go index a7e3399d..ea90f52b 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -583,7 +583,7 @@ func (c *ChannelGraph) PruneGraph(spentOutputs []*wire.OutPoint, // current UTXO state. var newTip [pruneTipBytes]byte copy(newTip[:], blockHash[:]) - byteOrder.PutUint32(newTip[32:], uint32(blockHeight)) + byteOrder.PutUint32(newTip[32:], blockHeight) return metaBucket.Put(pruneTipKey, newTip[:]) }) diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index ca4383a5..10e288b9 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -1097,7 +1097,7 @@ func normalizeFunc(edges []*lnrpc.ChannelEdge, scaleFactor float64) func(int64) y := math.Log2(float64(x)) // TODO(roasbeef): results in min being zero - return float64(y-min) / float64(max-min) * scaleFactor + return y-min / max-min * scaleFactor } } diff --git a/htlcswitch.go b/htlcswitch.go index 2b1db562..018f0fb8 100644 --- a/htlcswitch.go +++ b/htlcswitch.go @@ -256,7 +256,7 @@ out: } wireMsg := htlcPkt.msg.(*lnwire.UpdateAddHTLC) - amt := btcutil.Amount(wireMsg.Amount) + amt := wireMsg.Amount // Handle this send request in a distinct goroutine in // order to avoid a possible deadlock between the htlc diff --git a/lnwire/lnwire.go b/lnwire/lnwire.go index 3ae9e389..161a4a72 100644 --- a/lnwire/lnwire.go +++ b/lnwire/lnwire.go @@ -62,13 +62,13 @@ func writeElement(w io.Writer, element interface{}) error { switch e := element.(type) { case uint8: var b [1]byte - b[0] = byte(e) + b[0] = e if _, err := w.Write(b[:]); err != nil { return err } case uint16: var b [2]byte - binary.BigEndian.PutUint16(b[:], uint16(e)) + binary.BigEndian.PutUint16(b[:], e) if _, err := w.Write(b[:]); err != nil { return err } @@ -86,13 +86,13 @@ func writeElement(w io.Writer, element interface{}) error { } case uint32: var b [4]byte - binary.BigEndian.PutUint32(b[:], uint32(e)) + binary.BigEndian.PutUint32(b[:], e) if _, err := w.Write(b[:]); err != nil { return err } case uint64: var b [8]byte - binary.BigEndian.PutUint64(b[:], uint64(e)) + binary.BigEndian.PutUint64(b[:], e) if _, err := w.Write(b[:]); err != nil { return err } diff --git a/lnwire/signature.go b/lnwire/signature.go index 2eea5f4b..ce049736 100644 --- a/lnwire/signature.go +++ b/lnwire/signature.go @@ -19,8 +19,8 @@ func serializeSigToWire(b *[64]byte, e *btcec.Signature) error { // is the second byte after R ends. 0x02 signifies a length-prefixed, // zero-padded, big-endian bigint. 0x30 sigifies a DER signature. // See the Serialize() method for btcec.Signature for details. - rLen := uint8(sig[3]) - sLen := uint8(sig[5+rLen]) + rLen := sig[3] + sLen := sig[5+rLen] // Check to make sure R and S can both fit into their intended buffers. // We check S first because these code blocks decrement sLen and diff --git a/peer.go b/peer.go index 8208ca2e..f8cde640 100644 --- a/peer.go +++ b/peer.go @@ -1766,7 +1766,7 @@ func logEntryToHtlcPkt(chanPoint wire.OutPoint, } htlc := &lnwire.UpdateAddHTLC{ - Amount: btcutil.Amount(pd.Amount), + Amount: pd.Amount, PaymentHash: pd.RHash, } copy(htlc.OnionBlob[:], b.Bytes()) diff --git a/rpcserver.go b/rpcserver.go index b478eacc..bbbfe381 100644 --- a/rpcserver.go +++ b/rpcserver.go @@ -871,7 +871,7 @@ func (r *rpcServer) savePayment(route *routing.Route, amount btcutil.Amount, payment := &channeldb.OutgoingPayment{ Invoice: channeldb.Invoice{ Terms: channeldb.ContractTerm{ - Value: btcutil.Amount(amount), + Value: amount, }, CreationDate: time.Now(), }, diff --git a/utxonursery.go b/utxonursery.go index 33d749ca..dfeb52b8 100644 --- a/utxonursery.go +++ b/utxonursery.go @@ -432,7 +432,7 @@ func (k *kidOutput) waitForPromotion(db *channeldb.DB, confChan *chainntnfs.Conf utxnLog.Infof("Outpoint %v confirmed in block %v moving to kindergarten", k.outPoint, txConfirmation.BlockHeight) - k.confHeight = uint32(txConfirmation.BlockHeight) + k.confHeight = txConfirmation.BlockHeight // The following block deletes a kidOutput from the preschool database // bucket and adds it to the kindergarten database bucket which is @@ -462,7 +462,7 @@ func (k *kidOutput) waitForPromotion(db *channeldb.DB, confChan *chainntnfs.Conf maturityHeight := k.confHeight + k.blocksToMaturity heightBytes := make([]byte, 4) - byteOrder.PutUint32(heightBytes, uint32(maturityHeight)) + byteOrder.PutUint32(heightBytes, maturityHeight) // If there're any existing outputs for this particular block // height target, then we'll append this new output to the @@ -675,7 +675,7 @@ func deleteGraduatedOutputs(db *channeldb.DB, deleteHeight uint32) error { } heightBytes := make([]byte, 4) - byteOrder.PutUint32(heightBytes, uint32(deleteHeight)) + byteOrder.PutUint32(heightBytes, deleteHeight) results := kgtnBucket.Get(heightBytes) if results == nil { return nil