lnd: fix unconvert warnings

This commit is contained in:
Andrey Samokhvalov 2017-02-23 22:07:01 +03:00 committed by Olaoluwa Osuntokun
parent f2843dd4c9
commit 143a6e01bb
10 changed files with 18 additions and 18 deletions

@ -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,

@ -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)
}

@ -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[:])
})

@ -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
}
}

@ -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

@ -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
}

@ -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

@ -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())

@ -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(),
},

@ -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