mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 17:43:07 +02:00
peer: always send channel update on reconnect
We have existing logic to attempt to reliably send a channel update to the remote peer. In the wild, we've seen this fail, as it's possible right when we send the update the peer disconnects. In this commit, we implement a simple fix which is just to send the chan update each time we connect to the remote party. Fixes https://github.com/lightningnetwork/lnd/issues/6870.
This commit is contained in:
@@ -341,6 +341,7 @@ func createTestPeerWithChannel(t *testing.T, updateChan func(a,
|
||||
notifier: notifier,
|
||||
publishTx: publishTx,
|
||||
mockSwitch: mockSwitch,
|
||||
mockConn: params.mockConn,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -493,10 +494,14 @@ func (m *mockMessageConn) Flush() (int, error) {
|
||||
// the bytes sent into the mock's writtenMessages channel.
|
||||
func (m *mockMessageConn) WriteMessage(msg []byte) error {
|
||||
m.writeRaceDetectingCounter++
|
||||
|
||||
msgCopy := make([]byte, len(msg))
|
||||
copy(msgCopy, msg)
|
||||
|
||||
select {
|
||||
case m.writtenMessages <- msg:
|
||||
case m.writtenMessages <- msgCopy:
|
||||
case <-time.After(timeout):
|
||||
m.t.Fatalf("timeout sending message: %v", msg)
|
||||
m.t.Fatalf("timeout sending message: %v", msgCopy)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -713,6 +718,11 @@ func createTestPeer(t *testing.T) *peerTestCtx {
|
||||
return nil
|
||||
},
|
||||
PongBuf: make([]byte, lnwire.MaxPongBytes),
|
||||
FetchLastChanUpdate: func(chanID lnwire.ShortChannelID,
|
||||
) (*lnwire.ChannelUpdate, error) {
|
||||
|
||||
return &lnwire.ChannelUpdate{}, nil
|
||||
},
|
||||
}
|
||||
|
||||
alicePeer := NewBrontide(*cfg)
|
||||
|
Reference in New Issue
Block a user