lnd: fix latest goclean.sh lint warning
This commit is contained in:
parent
730c0b8cb1
commit
61991a1c89
@ -11,7 +11,7 @@
|
||||
[![Godoc](https://godoc.org/github.com/lightningnetwork/lnd?status.svg)]
|
||||
(https://godoc.org/github.com/lightningnetwork/lnd)
|
||||
|
||||
[![Coverage Status](https://coveralls.io/repos/github/AndrewSamokhvalov/lnd/badge.svg?branch=master)](https://coveralls.io/github/AndrewSamokhvalov/lnd?branch=master)
|
||||
[![Coverage Status](https://coveralls.io/repos/github/lightningnetwork/lnd/badge.svg?branch=master)](https://coveralls.io/github/lightningnetwork/lnd?branch=master)
|
||||
|
||||
The Lightning Network Daemon (`lnd`) - is a complete implementation of a
|
||||
[Lightning Network](https://lightning.network) node and currently
|
||||
|
@ -1453,7 +1453,7 @@ func putChanFundingInfo(nodeChanBucket *bolt.Bucket, channel *OpenChannel) error
|
||||
return err
|
||||
}
|
||||
|
||||
byteOrder.PutUint16(scratch[:2], uint16(channel.NumConfsRequired))
|
||||
byteOrder.PutUint16(scratch[:2], channel.NumConfsRequired)
|
||||
if _, err := b.Write(scratch[:2]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -346,7 +346,7 @@ func fetchChannels(d *DB, pendingOnly bool) ([]*OpenChannel, error) {
|
||||
}
|
||||
if pendingOnly {
|
||||
for _, channel := range nodeChannels {
|
||||
if channel.IsPending == true {
|
||||
if channel.IsPending {
|
||||
channels = append(channels, channel)
|
||||
}
|
||||
}
|
||||
@ -363,7 +363,7 @@ func fetchChannels(d *DB, pendingOnly bool) ([]*OpenChannel, error) {
|
||||
// MarkChannelAsOpen records the finalization of the funding process and marks
|
||||
// a channel as available for use.
|
||||
func (d *DB) MarkChannelAsOpen(outpoint *wire.OutPoint) error {
|
||||
err := d.Update(func(tx *bolt.Tx) error {
|
||||
return d.Update(func(tx *bolt.Tx) error {
|
||||
openChanBucket := tx.Bucket(openChannelBucket)
|
||||
if openChanBucket == nil {
|
||||
return ErrNoActiveChannels
|
||||
@ -385,11 +385,6 @@ func (d *DB) MarkChannelAsOpen(outpoint *wire.OutPoint) error {
|
||||
byteOrder.PutUint16(scratch, uint16(0))
|
||||
return openChanBucket.Put(keyPrefix, scratch)
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// syncVersions function is used for safe db version synchronization. It applies
|
||||
|
@ -751,8 +751,8 @@ func delChannelByEdge(edges *bolt.Bucket, edgeIndex *bolt.Bucket,
|
||||
// updated, otherwise it's the second node's information. The node ordering is
|
||||
// determined tby the lexicographical ordering of the identity public keys of
|
||||
// the nodes on either side of the channel.
|
||||
func (r *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
|
||||
return r.db.Update(func(tx *bolt.Tx) error {
|
||||
func (c *ChannelGraph) UpdateEdgePolicy(edge *ChannelEdgePolicy) error {
|
||||
return c.db.Update(func(tx *bolt.Tx) error {
|
||||
edges, err := tx.CreateBucketIfNotExists(edgeBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -1096,7 +1096,7 @@ func normalizeFunc(edges []*lnrpc.ChannelEdge, scaleFactor float64) func(int64)
|
||||
y := math.Log2(float64(x))
|
||||
|
||||
// TODO(roasbeef): results in min being zero
|
||||
return y - min/max - min*scaleFactor
|
||||
return (y - min) / (max - min) * scaleFactor
|
||||
}
|
||||
}
|
||||
|
||||
@ -1259,21 +1259,21 @@ func getChanInfo(ctx *cli.Context) error {
|
||||
defer cleanUp()
|
||||
|
||||
var (
|
||||
chan_id int64
|
||||
err error
|
||||
chanID int64
|
||||
err error
|
||||
)
|
||||
|
||||
switch {
|
||||
case ctx.IsSet("chan_id"):
|
||||
chan_id = ctx.Int64("chan_id")
|
||||
chanID = ctx.Int64("chan_id")
|
||||
case ctx.Args().Present():
|
||||
chan_id, err = strconv.ParseInt(ctx.Args().First(), 10, 64)
|
||||
chanID, err = strconv.ParseInt(ctx.Args().First(), 10, 64)
|
||||
default:
|
||||
return fmt.Errorf("chan_id argument missing")
|
||||
}
|
||||
|
||||
req := &lnrpc.ChanInfoRequest{
|
||||
ChanId: uint64(chan_id),
|
||||
ChanId: uint64(chanID),
|
||||
}
|
||||
|
||||
chanInfo, err := client.GetChanInfo(ctxb, req)
|
||||
@ -1491,11 +1491,11 @@ func decodePayReq(ctx *cli.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
var ListChainTxns = cli.Command{
|
||||
var listChainTxnsCommand = cli.Command{
|
||||
Name: "listchaintxns",
|
||||
Usage: "List transactions from the wallet.",
|
||||
Description: "List all transactions an address of the wallet was involved in.",
|
||||
Action: listChainTxns,
|
||||
Action: listChainTxns,
|
||||
}
|
||||
|
||||
func listChainTxns(ctx *cli.Context) error {
|
||||
@ -1509,6 +1509,6 @@ func listChainTxns(ctx *cli.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
printRespJson(resp)
|
||||
printRespJSON(resp)
|
||||
return nil
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ func main() {
|
||||
getNetworkInfoCommand,
|
||||
debugLevelCommand,
|
||||
decodePayReqComamnd,
|
||||
ListChainTxns,
|
||||
listChainTxnsCommand,
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
|
@ -1097,13 +1097,13 @@ func newChanAnnouncement(localIdentity, remotePub *btcec.PublicKey,
|
||||
// network to recognize the legitimacy of the channel. The crafted
|
||||
// announcements are then send to the channel router to handle broadcasting to
|
||||
// the network during its next trickle.
|
||||
func (f *fundingManager) announceChannel(idKey, remoteIdKey *btcec.PublicKey,
|
||||
func (f *fundingManager) announceChannel(idKey, remoteIDKey *btcec.PublicKey,
|
||||
channel *lnwallet.LightningChannel, chanID lnwire.ChannelID, localProof,
|
||||
remoteProof *channelProof) {
|
||||
|
||||
// TODO(roasbeef): need a Signer.SignMessage method to finalize
|
||||
// advertisements
|
||||
chanAnnouncement := newChanAnnouncement(idKey, remoteIdKey, channel, chanID,
|
||||
chanAnnouncement := newChanAnnouncement(idKey, remoteIDKey, channel, chanID,
|
||||
localProof, remoteProof)
|
||||
|
||||
f.cfg.SendToRouter(chanAnnouncement.chanAnn)
|
||||
|
16
lnd_test.go
16
lnd_test.go
@ -200,7 +200,7 @@ func closeChannelAndAssert(ctx context.Context, t *harnessTest, net *networkHarn
|
||||
// numChannelsPending sends an RPC request to a node to get a count of the
|
||||
// node's channels that are currently in a pending state (with a broadcast,
|
||||
// but not confirmed funding transaction).
|
||||
func numChannelsPending(node *lightningNode, ctxt context.Context) (int, error) {
|
||||
func numChannelsPending(ctxt context.Context, node *lightningNode) (int, error) {
|
||||
pendingChansRequest := &lnrpc.PendingChannelRequest{
|
||||
Status: lnrpc.ChannelStatus_OPENING,
|
||||
}
|
||||
@ -213,14 +213,14 @@ func numChannelsPending(node *lightningNode, ctxt context.Context) (int, error)
|
||||
|
||||
// assertNumChannelsPending asserts that a pair of nodes have the expected
|
||||
// number of pending channels between them.
|
||||
func assertNumChannelsPending(t *harnessTest, ctxt context.Context,
|
||||
func assertNumChannelsPending(ctxt context.Context, t *harnessTest,
|
||||
alice, bob *lightningNode, expected int) {
|
||||
aliceNumChans, err := numChannelsPending(alice, ctxt)
|
||||
aliceNumChans, err := numChannelsPending(ctxt, alice)
|
||||
if err != nil {
|
||||
t.Fatalf("error fetching alice's node (%v) pending channels %v",
|
||||
alice.nodeID, err)
|
||||
}
|
||||
bobNumChans, err := numChannelsPending(bob, ctxt)
|
||||
bobNumChans, err := numChannelsPending(ctxt, bob)
|
||||
if err != nil {
|
||||
t.Fatalf("error fetching bob's node (%v) pending channels %v",
|
||||
bob.nodeID, err)
|
||||
@ -313,7 +313,7 @@ func testChannelFundingPersistence(net *networkHarness, t *harnessTest) {
|
||||
// been broadcast, but not confirmed. Alice and Bob's nodes
|
||||
// should reflect this when queried via RPC.
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
assertNumChannelsPending(t, ctxt, net.Alice, net.Bob, 1)
|
||||
assertNumChannelsPending(ctxt, t, net.Alice, net.Bob, 1)
|
||||
|
||||
// Restart both nodes to test that the appropriate state has been
|
||||
// persisted and that both nodes recover gracefully.
|
||||
@ -376,7 +376,7 @@ peersPoll:
|
||||
// Both nodes should still show a single channel as pending.
|
||||
time.Sleep(time.Millisecond * 300)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
assertNumChannelsPending(t, ctxt, net.Alice, net.Bob, 1)
|
||||
assertNumChannelsPending(ctxt, t, net.Alice, net.Bob, 1)
|
||||
|
||||
// Finally, mine the last block which should mark the channel as open.
|
||||
if _, err := net.Miner.Node.Generate(1); err != nil {
|
||||
@ -387,7 +387,7 @@ peersPoll:
|
||||
// be no pending channels remaining for either node.
|
||||
time.Sleep(time.Millisecond * 300)
|
||||
ctxt, _ = context.WithTimeout(ctxb, timeout)
|
||||
assertNumChannelsPending(t, ctxt, net.Alice, net.Bob, 0)
|
||||
assertNumChannelsPending(ctxt, t, net.Alice, net.Bob, 0)
|
||||
|
||||
// The channel should be listed in the peer information returned by
|
||||
// both peers.
|
||||
@ -1009,7 +1009,7 @@ func testMultiHopPayments(net *networkHarness, t *harnessTest) {
|
||||
}
|
||||
if len(chanGraph.Edges) != 2 {
|
||||
t.Fatalf("only two channels should be seen as active in the "+
|
||||
"network, instead %v are: ", len(chanGraph.Edges),
|
||||
"network, instead %v are: %v", len(chanGraph.Edges),
|
||||
chanGraph.Edges)
|
||||
}
|
||||
for _, link := range chanGraph.Edges {
|
||||
|
@ -49,15 +49,10 @@ var _ Message = (*FundingLocked)(nil)
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *FundingLocked) Decode(r io.Reader, pver uint32) error {
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelOutpoint,
|
||||
&c.ChannelID,
|
||||
&c.NextPerCommitmentPoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target FundingLocked message into the passed io.Writer
|
||||
@ -66,15 +61,10 @@ func (c *FundingLocked) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *FundingLocked) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelOutpoint,
|
||||
c.ChannelID,
|
||||
c.NextPerCommitmentPoint)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the uint32 code which uniquely identifies this message as a
|
||||
@ -111,7 +101,8 @@ func (c *FundingLocked) MaxPayloadLength(uint32) uint32 {
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *FundingLocked) Validate() error {
|
||||
if c.NextPerCommitmentPoint == nil {
|
||||
return fmt.Errorf("The next per commitment point must be non-nil.")
|
||||
return fmt.Errorf("the next per commitment point must be " +
|
||||
"non-nil.")
|
||||
}
|
||||
|
||||
// We're good!
|
||||
|
@ -112,7 +112,7 @@ func NewSingleFundingRequest(chanID uint64, chanType uint8, coinType uint64,
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *SingleFundingRequest) Decode(r io.Reader, pver uint32) error {
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelID,
|
||||
&c.ChannelType,
|
||||
&c.CoinType,
|
||||
@ -125,11 +125,6 @@ func (c *SingleFundingRequest) Decode(r io.Reader, pver uint32) error {
|
||||
&c.DeliveryPkScript,
|
||||
&c.DustLimit,
|
||||
&c.ConfirmationDepth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target SingleFundingRequest into the passed io.Writer
|
||||
@ -138,7 +133,7 @@ func (c *SingleFundingRequest) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *SingleFundingRequest) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelID,
|
||||
c.ChannelType,
|
||||
c.CoinType,
|
||||
@ -151,11 +146,6 @@ func (c *SingleFundingRequest) Encode(w io.Writer, pver uint32) error {
|
||||
c.DeliveryPkScript,
|
||||
c.DustLimit,
|
||||
c.ConfirmationDepth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the uint32 code which uniquely identifies this message as a
|
||||
@ -179,7 +169,7 @@ func (c *SingleFundingRequest) MaxPayloadLength(uint32) uint32 {
|
||||
length += 8
|
||||
|
||||
// ChannelType - 1 byte
|
||||
length += 1
|
||||
length++
|
||||
|
||||
// CoinType - 8 bytes
|
||||
length += 8
|
||||
|
@ -94,7 +94,7 @@ func (c *SingleFundingResponse) Decode(r io.Reader, pver uint32) error {
|
||||
// DeliveryPkScript (final delivery)
|
||||
// DustLimit (8)
|
||||
// ConfirmationDepth (4)
|
||||
err := readElements(r,
|
||||
return readElements(r,
|
||||
&c.ChannelID,
|
||||
&c.ChannelDerivationPoint,
|
||||
&c.CommitmentKey,
|
||||
@ -103,11 +103,6 @@ func (c *SingleFundingResponse) Decode(r io.Reader, pver uint32) error {
|
||||
&c.DeliveryPkScript,
|
||||
&c.DustLimit,
|
||||
&c.ConfirmationDepth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Encode serializes the target SingleFundingResponse into the passed io.Writer
|
||||
@ -116,7 +111,7 @@ func (c *SingleFundingResponse) Decode(r io.Reader, pver uint32) error {
|
||||
//
|
||||
// This is part of the lnwire.Message interface.
|
||||
func (c *SingleFundingResponse) Encode(w io.Writer, pver uint32) error {
|
||||
err := writeElements(w,
|
||||
return writeElements(w,
|
||||
c.ChannelID,
|
||||
c.ChannelDerivationPoint,
|
||||
c.CommitmentKey,
|
||||
@ -125,11 +120,6 @@ func (c *SingleFundingResponse) Encode(w io.Writer, pver uint32) error {
|
||||
c.DeliveryPkScript,
|
||||
c.DustLimit,
|
||||
c.ConfirmationDepth)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Command returns the uint32 code which uniquely identifies this message as a
|
||||
|
@ -107,11 +107,11 @@ func (r *ChannelRouter) notifyTopologyChange(topologyDiff *TopologyChange) {
|
||||
|
||||
// In this case we'll try to send the notification
|
||||
// directly to the upstream client consumer.
|
||||
case client.ntfnChan <- topologyDiff:
|
||||
case c.ntfnChan <- topologyDiff:
|
||||
|
||||
// If the client cancel's the notifications, then we'll
|
||||
// exit early.
|
||||
case <-client.exit:
|
||||
case <-c.exit:
|
||||
|
||||
// Similarly, if the ChannelRouter itself exists early,
|
||||
// then we'll also exit ourselves.
|
||||
|
@ -664,7 +664,7 @@ func TestChannelCloseNotification(t *testing.T) {
|
||||
Transactions: []*wire.MsgTx{
|
||||
{
|
||||
TxIn: []*wire.TxIn{
|
||||
&wire.TxIn{
|
||||
{
|
||||
PreviousOutPoint: chanUtxo,
|
||||
},
|
||||
},
|
||||
|
@ -4,11 +4,6 @@ import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
"github.com/roasbeef/btcd/chaincfg/chainhash"
|
||||
"github.com/roasbeef/btcd/wire"
|
||||
"github.com/roasbeef/btcutil"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"net"
|
||||
@ -17,13 +12,13 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
prand "math/rand"
|
||||
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/roasbeef/btcd/btcec"
|
||||
"github.com/roasbeef/btcd/chaincfg/chainhash"
|
||||
"github.com/roasbeef/btcd/wire"
|
||||
"github.com/roasbeef/btcutil"
|
||||
|
||||
prand "math/rand"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -344,8 +339,7 @@ func TestBasicGraphPathFinding(t *testing.T) {
|
||||
// The length of the path should be exactly one hop as it's the
|
||||
// "shortest" known path in the graph.
|
||||
if len(route.Hops) != 1 {
|
||||
t.Fatalf("shortest path not selected, should be of length 1, "+
|
||||
"is instead: %v", len(route.Hops))
|
||||
t.Fatalf("shortest path not selected, should be of length 1, "+"is instead: %v", len(route.Hops))
|
||||
}
|
||||
|
||||
// As we have a direct path, the total time lock value should be
|
||||
@ -388,8 +382,7 @@ func TestNewRoutePathTooLong(t *testing.T) {
|
||||
target = aliases["vincent"]
|
||||
route, err = findRoute(graph, target, paymentAmt)
|
||||
if err == nil {
|
||||
t.Fatalf("should not have been able to find path, supposed to be "+
|
||||
"greater than 20 hops, found route with %v hops", len(route.Hops))
|
||||
t.Fatalf("should not have been able to find path, supposed to be "+"greater than 20 hops, found route with %v hops", len(route.Hops))
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -85,9 +85,6 @@ func (p *RevocationProducer) AtIndex(v uint64) (*chainhash.Hash, error) {
|
||||
//
|
||||
// NOTE: Part of the Producer interface.
|
||||
func (p *RevocationProducer) Encode(w io.Writer) error {
|
||||
if _, err := w.Write(p.root.hash[:]); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
_, err := w.Write(p.root.hash[:])
|
||||
return err
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user