multi: extend lnpeer.Peer interface with Disconnect function

This will be used in the gossiper to disconnect from peers if their
ban score passes the ban threshold.
This commit is contained in:
Eugene Siegel
2024-08-14 14:03:39 -04:00
parent 0173e4c44d
commit 99b86ba462
8 changed files with 78 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ import (
"errors"
"net"
"sync"
"sync/atomic"
"github.com/btcsuite/btcd/btcec/v2"
"github.com/btcsuite/btcd/wire"
@@ -14,9 +15,10 @@ import (
// mockPeer implements the lnpeer.Peer interface and is used to test the
// gossiper's interaction with peers.
type mockPeer struct {
pk *btcec.PublicKey
sentMsgs chan lnwire.Message
quit chan struct{}
pk *btcec.PublicKey
sentMsgs chan lnwire.Message
quit chan struct{}
disconnected atomic.Bool
}
var _ lnpeer.Peer = (*mockPeer)(nil)
@@ -74,6 +76,10 @@ func (p *mockPeer) RemovePendingChannel(_ lnwire.ChannelID) error {
return nil
}
func (p *mockPeer) Disconnect(err error) {
p.disconnected.Store(true)
}
// mockMessageStore is an in-memory implementation of the MessageStore interface
// used for the gossiper's unit tests.
type mockMessageStore struct {