discovery/gossiper: update to latest NotifyWhenOnline changes
This commit is contained in:
parent
04c5eba194
commit
6d4da72156
@ -107,7 +107,9 @@ type Config struct {
|
|||||||
// NotifyWhenOnline is a function that allows the gossiper to be
|
// NotifyWhenOnline is a function that allows the gossiper to be
|
||||||
// notified when a certain peer comes online, allowing it to
|
// notified when a certain peer comes online, allowing it to
|
||||||
// retry sending a peer message.
|
// retry sending a peer message.
|
||||||
NotifyWhenOnline func(peer *btcec.PublicKey, connectedChan chan<- struct{})
|
//
|
||||||
|
// NOTE: The peerChan channel must be buffered.
|
||||||
|
NotifyWhenOnline func(peer *btcec.PublicKey, peerChan chan<- lnpeer.Peer)
|
||||||
|
|
||||||
// ProofMatureDelta the number of confirmations which is needed before
|
// ProofMatureDelta the number of confirmations which is needed before
|
||||||
// exchange the channel announcement proofs.
|
// exchange the channel announcement proofs.
|
||||||
@ -2399,13 +2401,13 @@ func (d *AuthenticatedGossiper) sendAnnSigReliably(
|
|||||||
"to peer(%x): %v. Will retry when online.",
|
"to peer(%x): %v. Will retry when online.",
|
||||||
remotePeer.SerializeCompressed(), err)
|
remotePeer.SerializeCompressed(), err)
|
||||||
|
|
||||||
connected := make(chan struct{})
|
peerChan := make(chan lnpeer.Peer, 1)
|
||||||
d.cfg.NotifyWhenOnline(remotePeer, connected)
|
d.cfg.NotifyWhenOnline(remotePeer, peerChan)
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-connected:
|
case <-peerChan:
|
||||||
// Retry sending.
|
// Retry sending.
|
||||||
log.Infof("peer %x reconnected. Retry sending"+
|
log.Infof("Peer %x reconnected. Retry sending"+
|
||||||
" AnnounceSignatures.",
|
" AnnounceSignatures.",
|
||||||
remotePeer.SerializeCompressed())
|
remotePeer.SerializeCompressed())
|
||||||
|
|
||||||
|
@ -1187,9 +1187,9 @@ func TestSignatureAnnouncementRetry(t *testing.T) {
|
|||||||
// We expect the gossiper to register for a notification when the peer
|
// We expect the gossiper to register for a notification when the peer
|
||||||
// comes back online, so keep track of the channel it wants to get
|
// comes back online, so keep track of the channel it wants to get
|
||||||
// notified on.
|
// notified on.
|
||||||
notifyPeers := make(chan chan<- struct{}, 1)
|
notifyPeers := make(chan chan<- lnpeer.Peer, 1)
|
||||||
ctx.gossiper.cfg.NotifyWhenOnline = func(peer *btcec.PublicKey,
|
ctx.gossiper.cfg.NotifyWhenOnline = func(peer *btcec.PublicKey,
|
||||||
connectedChan chan<- struct{}) {
|
connectedChan chan<- lnpeer.Peer) {
|
||||||
notifyPeers <- connectedChan
|
notifyPeers <- connectedChan
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1208,7 +1208,7 @@ func TestSignatureAnnouncementRetry(t *testing.T) {
|
|||||||
// Since sending this local announcement proof to the remote will fail,
|
// Since sending this local announcement proof to the remote will fail,
|
||||||
// the gossiper should register for a notification when the remote is
|
// the gossiper should register for a notification when the remote is
|
||||||
// online again.
|
// online again.
|
||||||
var conChan chan<- struct{}
|
var conChan chan<- lnpeer.Peer
|
||||||
select {
|
select {
|
||||||
case conChan = <-notifyPeers:
|
case conChan = <-notifyPeers:
|
||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
@ -1372,9 +1372,9 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
|
|||||||
msg ...lnwire.Message) error {
|
msg ...lnwire.Message) error {
|
||||||
return fmt.Errorf("intentional error in SendToPeer")
|
return fmt.Errorf("intentional error in SendToPeer")
|
||||||
}
|
}
|
||||||
notifyPeers := make(chan chan<- struct{}, 1)
|
notifyPeers := make(chan chan<- lnpeer.Peer, 1)
|
||||||
ctx.gossiper.cfg.NotifyWhenOnline = func(peer *btcec.PublicKey,
|
ctx.gossiper.cfg.NotifyWhenOnline = func(peer *btcec.PublicKey,
|
||||||
connectedChan chan<- struct{}) {
|
connectedChan chan<- lnpeer.Peer) {
|
||||||
notifyPeers <- connectedChan
|
notifyPeers <- connectedChan
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1392,7 +1392,7 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
|
|||||||
|
|
||||||
// Since sending to the remote peer will fail, the gossiper should
|
// Since sending to the remote peer will fail, the gossiper should
|
||||||
// register for a notification when it comes back online.
|
// register for a notification when it comes back online.
|
||||||
var conChan chan<- struct{}
|
var conChan chan<- lnpeer.Peer
|
||||||
select {
|
select {
|
||||||
case conChan = <-notifyPeers:
|
case conChan = <-notifyPeers:
|
||||||
case <-time.After(2 * time.Second):
|
case <-time.After(2 * time.Second):
|
||||||
@ -1431,7 +1431,7 @@ func TestSignatureAnnouncementRetryAtStartup(t *testing.T) {
|
|||||||
return fmt.Errorf("intentional error in SendToPeer")
|
return fmt.Errorf("intentional error in SendToPeer")
|
||||||
},
|
},
|
||||||
NotifyWhenOnline: func(peer *btcec.PublicKey,
|
NotifyWhenOnline: func(peer *btcec.PublicKey,
|
||||||
connectedChan chan<- struct{}) {
|
connectedChan chan<- lnpeer.Peer) {
|
||||||
notifyPeers <- connectedChan
|
notifyPeers <- connectedChan
|
||||||
},
|
},
|
||||||
Router: ctx.gossiper.cfg.Router,
|
Router: ctx.gossiper.cfg.Router,
|
||||||
@ -1607,9 +1607,9 @@ func TestSignatureAnnouncementFullProofWhenRemoteProof(t *testing.T) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyPeers := make(chan chan<- struct{}, 1)
|
notifyPeers := make(chan chan<- lnpeer.Peer, 1)
|
||||||
ctx.gossiper.cfg.NotifyWhenOnline = func(peer *btcec.PublicKey,
|
ctx.gossiper.cfg.NotifyWhenOnline = func(peer *btcec.PublicKey,
|
||||||
connectedChan chan<- struct{}) {
|
connectedChan chan<- lnpeer.Peer) {
|
||||||
notifyPeers <- connectedChan
|
notifyPeers <- connectedChan
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2146,6 +2146,8 @@ type mockPeer struct {
|
|||||||
quit chan struct{}
|
quit chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var _ lnpeer.Peer = (*mockPeer)(nil)
|
||||||
|
|
||||||
func (p *mockPeer) SendMessage(_ bool, msgs ...lnwire.Message) error {
|
func (p *mockPeer) SendMessage(_ bool, msgs ...lnwire.Message) error {
|
||||||
if p.sentMsgs == nil && p.quit == nil {
|
if p.sentMsgs == nil && p.quit == nil {
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user