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 2017-11-23 01:15:21 -06:00
parent 3aabbce551
commit 25082f0b5b
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21
4 changed files with 10 additions and 8 deletions

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

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

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

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