peer: add SendMessageLazy
This commit is contained in:
6 files changed
+54
-8
No files matched your search
@@ -2351,12 +2351,31 @@ func (p *peer) resendChanSyncMsg(cid lnwire.ChannelID) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SendMessage sends a variadic number of message to remote peer. The first
|
||||
// argument denotes if the method should block until the message has been sent
|
||||
// to the remote peer.
|
||||
// SendMessage sends a variadic number of high-priority message to remote peer.
|
||||
// The first argument denotes if the method should block until the messages have
|
||||
// been sent to the remote peer or an error is returned, otherwise it returns
|
||||
// immediately after queuing.
|
||||
//
|
||||
// NOTE: Part of the lnpeer.Peer interface.
|
||||
func (p *peer) SendMessage(sync bool, msgs ...lnwire.Message) error {
|
||||
return p.sendMessage(sync, true, msgs...)
|
||||
}
|
||||
|
||||
// SendMessageLazy sends a variadic number of low-priority message to remote
|
||||
// peer. The first argument denotes if the method should block until the
|
||||
// messages have been sent to the remote peer or an error is returned, otherwise
|
||||
// it returns immediately after queueing.
|
||||
//
|
||||
// NOTE: Part of the lnpeer.Peer interface.
|
||||
func (p *peer) SendMessageLazy(sync bool, msgs ...lnwire.Message) error {
|
||||
return p.sendMessage(sync, false, msgs...)
|
||||
}
|
||||
|
||||
// sendMessage queues a variadic number of messages using the passed priority
|
||||
// to the remote peer. If sync is true, this method will block until the
|
||||
// messages have been sent to the remote peer or an error is returned, otherwise
|
||||
// it returns immediately after queueing.
|
||||
func (p *peer) sendMessage(sync, priority bool, msgs ...lnwire.Message) error {
|
||||
// Add all incoming messages to the outgoing queue. A list of error
|
||||
// chans is populated for each message if the caller requested a sync
|
||||
// send.
|
||||
@@ -2370,7 +2389,11 @@ func (p *peer) SendMessage(sync bool, msgs ...lnwire.Message) error {
|
||||
errChans = append(errChans, errChan)
|
||||
}
|
||||
|
||||
p.queueMsg(msg, errChan)
|
||||
if priority {
|
||||
p.queueMsg(msg, errChan)
|
||||
} else {
|
||||
p.queueMsgLazy(msg, errChan)
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for all replies from the writeHandler. For async sends, this
|
||||
|
||||
Reference in new issue
Block a user