From 25082f0b5bcb55757a4f96a2108d4554f328815b Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 23 Nov 2017 01:15:21 -0600 Subject: [PATCH] htlcswitch: update WipeChannel on Peer interface to simply take the chanPoint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The WipeChannel method doesn’t need to take the channel itself, as any relevant indexes should be able to be queried based on the channel point along. --- htlcswitch/interfaces.go | 8 ++++---- htlcswitch/link.go | 5 +++-- htlcswitch/link_test.go | 3 ++- htlcswitch/mock.go | 2 +- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/htlcswitch/interfaces.go b/htlcswitch/interfaces.go index 04ea148c..8f1a48f7 100644 --- a/htlcswitch/interfaces.go +++ b/htlcswitch/interfaces.go @@ -2,9 +2,9 @@ package htlcswitch import ( "github.com/lightningnetwork/lnd/channeldb" - "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" "github.com/roasbeef/btcd/chaincfg/chainhash" + "github.com/roasbeef/btcd/wire" ) // InvoiceDatabase is an interface which represents the persistent subsystem @@ -97,9 +97,9 @@ type Peer interface { // SendMessage sends message to remote peer. SendMessage(lnwire.Message) error - // WipeChannel removes the passed channel from all indexes associated - // with the peer. - WipeChannel(*lnwallet.LightningChannel) error + // WipeChannel removes the channel uniquely identified by its channel + // point from all indexes associated with the peer. + WipeChannel(*wire.OutPoint) error // PubKey returns the serialize public key of the source peer. PubKey() [33]byte diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 9f5522e5..64d9e934 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -422,13 +422,14 @@ out: // TODO(roasbeef): remove all together go func() { - if err := l.cfg.Peer.WipeChannel(l.channel); err != nil { + chanPoint := l.channel.ChannelPoint() + if err := l.cfg.Peer.WipeChannel(chanPoint); err != nil { log.Errorf("unable to wipe channel %v", err) } // TODO(roasbeef): need to send HTLC outputs to nursery // TODO(roasbeef): or let the arb sweep? - l.cfg.SettledContracts <- l.channel.ChannelPoint() + l.cfg.SettledContracts <- chanPoint }() break out diff --git a/htlcswitch/link_test.go b/htlcswitch/link_test.go index 40220efb..6d9aa121 100644 --- a/htlcswitch/link_test.go +++ b/htlcswitch/link_test.go @@ -20,6 +20,7 @@ import ( "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" "github.com/roasbeef/btcd/chaincfg/chainhash" + "github.com/roasbeef/btcd/wire" "github.com/roasbeef/btcutil" ) @@ -1396,7 +1397,7 @@ func (m *mockPeer) SendMessage(msg lnwire.Message) error { m.Unlock() return nil } -func (m *mockPeer) WipeChannel(*lnwallet.LightningChannel) error { +func (m *mockPeer) WipeChannel(*wire.OutPoint) error { return nil } func (m *mockPeer) PubKey() [33]byte { diff --git a/htlcswitch/mock.go b/htlcswitch/mock.go index 98709293..20b9fbef 100644 --- a/htlcswitch/mock.go +++ b/htlcswitch/mock.go @@ -332,7 +332,7 @@ func (s *mockServer) Disconnect(reason error) { s.t.Fatalf("server %v was disconnected: %v", s.name, reason) } -func (s *mockServer) WipeChannel(*lnwallet.LightningChannel) error { +func (s *mockServer) WipeChannel(*wire.OutPoint) error { return nil }