From 545e84f4ce200ac140d19ef1a179e388470e5af5 Mon Sep 17 00:00:00 2001 From: naveen <172697+naveensrinivasan@users.noreply.github.com> Date: Mon, 13 Dec 2021 15:32:22 +0100 Subject: [PATCH] multi: formatting changes --- channeldb/channel.go | 5 +---- channeldb/graph.go | 18 ++++++++---------- channeldb/payments.go | 1 - lntest/harness_net.go | 2 -- lntest/itest/assertions.go | 1 - lnwire/writer.go | 1 - 6 files changed, 9 insertions(+), 19 deletions(-) diff --git a/channeldb/channel.go b/channeldb/channel.go index 2461efecb..00d95fe2a 100644 --- a/channeldb/channel.go +++ b/channeldb/channel.go @@ -1891,7 +1891,7 @@ func (k *CircuitKey) SetBytes(bs []byte) error { // Bytes returns the serialized bytes for this circuit key. func (k CircuitKey) Bytes() []byte { - var bs = make([]byte, 16) + bs := make([]byte, 16) binary.BigEndian.PutUint64(bs[:8], k.ChanID.ToUint64()) binary.BigEndian.PutUint64(bs[8:], k.HtlcID) return bs @@ -3468,7 +3468,6 @@ func putChanCommitments(chanBucket kvdb.RwBucket, channel *OpenChannel) error { } func putChanRevocationState(chanBucket kvdb.RwBucket, channel *OpenChannel) error { - var b bytes.Buffer err := WriteElements( &b, channel.RemoteCurrentRevocation, channel.RevocationProducer, @@ -3659,7 +3658,6 @@ func fetchChanRevocationState(chanBucket kvdb.RBucket, channel *OpenChannel) err } func deleteOpenChannel(chanBucket kvdb.RwBucket) error { - if err := chanBucket.Delete(chanInfoKey); err != nil { return err } @@ -3682,7 +3680,6 @@ func deleteOpenChannel(chanBucket kvdb.RwBucket) error { } return nil - } // makeLogKey converts a uint64 into an 8 byte array. diff --git a/channeldb/graph.go b/channeldb/graph.go index fc35dd659..7452bea8f 100644 --- a/channeldb/graph.go +++ b/channeldb/graph.go @@ -862,7 +862,6 @@ func (c *ChannelGraph) deleteLightningNode(nodes kvdb.RwBucket, } if err := nodes.Delete(compressedPubKey); err != nil { - return err } @@ -980,7 +979,6 @@ func (c *ChannelGraph) addChannelEdge(tx kvdb.RwTx, edge *ChannelEdgeInfo) error if err != nil { return fmt.Errorf("unable to create shell node "+ "for: %x", edge.NodeKey1Bytes) - } case node1Err != nil: return err @@ -997,7 +995,6 @@ func (c *ChannelGraph) addChannelEdge(tx kvdb.RwTx, edge *ChannelEdgeInfo) error if err != nil { return fmt.Errorf("unable to create shell node "+ "for: %x", edge.NodeKey2Bytes) - } case node2Err != nil: return err @@ -1012,11 +1009,12 @@ func (c *ChannelGraph) addChannelEdge(tx kvdb.RwTx, edge *ChannelEdgeInfo) error // Mark edge policies for both sides as unknown. This is to enable // efficient incoming channel lookup for a node. - for _, key := range []*[33]byte{&edge.NodeKey1Bytes, - &edge.NodeKey2Bytes} { - - err := putChanEdgePolicyUnknown(edges, edge.ChannelID, - key[:]) + keys := []*[33]byte{ + &edge.NodeKey1Bytes, + &edge.NodeKey2Bytes, + } + for _, key := range keys { + err := putChanEdgePolicyUnknown(edges, edge.ChannelID, key[:]) if err != nil { return err } @@ -2468,7 +2466,6 @@ func updateEdgePolicy(tx kvdb.RwTx, edge *ChannelEdgePolicy, edges := tx.ReadWriteBucket(edgeBucket) if edges == nil { return false, ErrEdgeNotFound - } edgeIndex := edges.NestedReadWriteBucket(edgeIndexBucket) if edgeIndex == nil { @@ -3125,7 +3122,8 @@ func (c *ChannelEdgeInfo) OtherNodeKeyBytes(thisNodeKey []byte) ( // the target node in the channel. This is useful when one knows the pubkey of // one of the nodes, and wishes to obtain the full LightningNode for the other // end of the channel. -func (c *ChannelEdgeInfo) FetchOtherNode(tx kvdb.RTx, thisNodeKey []byte) (*LightningNode, error) { +func (c *ChannelEdgeInfo) FetchOtherNode(tx kvdb.RTx, + thisNodeKey []byte) (*LightningNode, error) { // Ensure that the node passed in is actually a member of the channel. var targetNodeBytes [33]byte diff --git a/channeldb/payments.go b/channeldb/payments.go index 496b7a5fd..6450025a4 100644 --- a/channeldb/payments.go +++ b/channeldb/payments.go @@ -315,7 +315,6 @@ func fetchPayment(bucket kvdb.RBucket) (*MPPayment, error) { creationInfo, err := fetchCreationInfo(bucket) if err != nil { return nil, err - } var htlcs []HTLCAttempt diff --git a/lntest/harness_net.go b/lntest/harness_net.go index d864513d8..72e34122d 100644 --- a/lntest/harness_net.go +++ b/lntest/harness_net.go @@ -285,7 +285,6 @@ func extraArgsEtcd(etcdCfg *etcd.Config, name string, cluster bool) []string { if etcdCfg.InsecureSkipVerify { extraArgs = append(extraArgs, "--db.etcd.insecure_skip_verify") - } if cluster { @@ -619,7 +618,6 @@ func (n *NetworkHarness) EnsureConnected(t *testing.T, a, b *HarnessNode) { predErr = err return false } - }, DefaultTimeout) if err != nil { return fmt.Errorf("connection not succeeded within 15 "+ diff --git a/lntest/itest/assertions.go b/lntest/itest/assertions.go index 922e34de8..6304b92c1 100644 --- a/lntest/itest/assertions.go +++ b/lntest/itest/assertions.go @@ -570,7 +570,6 @@ func assertNotConnected(t *harnessTest, alice, bob *lntest.HarnessNode) { } return nil - }, defaultTimeout) require.NoError(t.t, err) } diff --git a/lnwire/writer.go b/lnwire/writer.go index 6a20c5715..0b08c951d 100644 --- a/lnwire/writer.go +++ b/lnwire/writer.go @@ -122,7 +122,6 @@ func WritePublicKey(buf *bytes.Buffer, pub *btcec.PublicKey) error { serializedPubkey := pub.SerializeCompressed() return WriteBytes(buf, serializedPubkey) - } // WriteChannelID appends the ChannelID to the provided buffer.