discovery: implement ChannelAnnouncement banning

This commit hooks up the banman to the gossiper:
- peers that are banned and don't have a channel with us will get
  disconnected until they are unbanned.
- peers that are banned and have a channel with us won't get
  disconnected, but we will ignore their channel announcements until
  they are no longer banned. Note that this only disables gossip of
  announcements to us and still allows us to open channels to them.
This commit is contained in:
Eugene Siegel
2024-08-16 14:16:20 -04:00
parent 9380292a5a
commit 013452cff0
7 changed files with 480 additions and 60 deletions

View File

@@ -161,3 +161,40 @@ func (s *mockMessageStore) MessagesForPeer(pubKey [33]byte) ([]lnwire.Message, e
return msgs, nil
}
type mockScidCloser struct {
m map[lnwire.ShortChannelID]struct{}
channelPeer bool
sync.Mutex
}
func newMockScidCloser(channelPeer bool) *mockScidCloser {
return &mockScidCloser{
m: make(map[lnwire.ShortChannelID]struct{}),
channelPeer: channelPeer,
}
}
func (m *mockScidCloser) PutClosedScid(scid lnwire.ShortChannelID) error {
m.Lock()
m.m[scid] = struct{}{}
m.Unlock()
return nil
}
func (m *mockScidCloser) IsClosedScid(scid lnwire.ShortChannelID) (bool,
error) {
m.Lock()
defer m.Unlock()
_, ok := m.m[scid]
return ok, nil
}
func (m *mockScidCloser) IsChannelPeer(pubkey *btcec.PublicKey) (bool, error) {
return m.channelPeer, nil
}