htlcswitch: update WipeChannel on Peer interface to simply take the chanPoint

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.
This commit is contained in:
Olaoluwa Osuntokun committed 2017-11-23 23:10:10 -06:00
1 parent 3aabbce551
commit 25082f0b5b
4 files changed
+10 -8

No files matched your search

+4 -4
View File
@@ -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
+3 -2
View File
@@ -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
+2 -1
View File
@@ -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 {
+1 -1
View File
@@ -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
}