mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-10 14:17:56 +01:00
discovery: add new msgsToBroadcast struct
This struct will be used to later on do filtering when we go to broadcast, based on if a message was locally sourced or granted from a remote peer.
This commit is contained in:
@@ -1028,6 +1028,31 @@ func (d *deDupedAnnouncements) AddMsgs(msgs ...networkMsg) {
|
||||
}
|
||||
}
|
||||
|
||||
// msgsToBroadcast is returned by Emit() and partitions the messages we'd like
|
||||
// to broadcast next into messages that are locally sourced and those that are
|
||||
// sourced remotely.
|
||||
type msgsToBroadcast struct {
|
||||
// localMsgs is the set of messages we created locally.
|
||||
localMsgs []msgWithSenders
|
||||
|
||||
// remoteMsgs is the set of messages that we received from a remote party.
|
||||
remoteMsgs []msgWithSenders
|
||||
}
|
||||
|
||||
// addMsg adds a new message to the appropriate sub-slice.
|
||||
func (m *msgsToBroadcast) addMsg(msg msgWithSenders) {
|
||||
if msg.isLocal {
|
||||
m.localMsgs = append(m.localMsgs, msg)
|
||||
} else {
|
||||
m.remoteMsgs = append(m.remoteMsgs, msg)
|
||||
}
|
||||
}
|
||||
|
||||
// isEmpty returns true if the batch is empty.
|
||||
func (m *msgsToBroadcast) isEmpty() bool {
|
||||
return len(m.localMsgs) == 0 && len(m.remoteMsgs) == 0
|
||||
}
|
||||
|
||||
// Emit returns the set of de-duplicated announcements to be sent out during
|
||||
// the next announcement epoch, in the order of channel announcements, channel
|
||||
// updates, and node announcements. Each message emitted, contains the set of
|
||||
|
||||
Reference in New Issue
Block a user