mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
htlcswitch: modify the SendMessage method on the Peer interface to optionally block
In this commit, add a new argument to the SendMessage method to allow callers to request that the method block until the message has been sent on the socket to the remote peer.
This commit is contained in:
parent
6fa93a78c1
commit
f53a99e18e
@ -111,8 +111,11 @@ type ChannelLink interface {
|
||||
// Peer is an interface which represents the remote lightning node inside our
|
||||
// system.
|
||||
type Peer interface {
|
||||
// SendMessage sends message to remote peer.
|
||||
SendMessage(lnwire.Message) error
|
||||
// SendMessage sends message to remote peer. The second arguments
|
||||
// denote if the method should block until the message has been sent to
|
||||
// the remote peer. If set, this allows the caller to more strongly
|
||||
// synchronize.
|
||||
SendMessage(msg lnwire.Message, sync bool) error
|
||||
|
||||
// WipeChannel removes the channel uniquely identified by its channel
|
||||
// point from all indexes associated with the peer.
|
||||
|
@ -1392,7 +1392,7 @@ type mockPeer struct {
|
||||
quit chan struct{}
|
||||
}
|
||||
|
||||
func (m *mockPeer) SendMessage(msg lnwire.Message) error {
|
||||
func (m *mockPeer) SendMessage(msg lnwire.Message, sync bool) error {
|
||||
select {
|
||||
case m.sentMsgs <- msg:
|
||||
case <-m.quit:
|
||||
|
@ -447,7 +447,7 @@ func (s *mockServer) intersect(f messageInterceptor) {
|
||||
s.interceptorFuncs = append(s.interceptorFuncs, f)
|
||||
}
|
||||
|
||||
func (s *mockServer) SendMessage(message lnwire.Message) error {
|
||||
func (s *mockServer) SendMessage(message lnwire.Message, sync bool) error {
|
||||
|
||||
select {
|
||||
case s.messages <- message:
|
||||
|
Loading…
Reference in New Issue
Block a user