discovery: move shouldBroadcast inside goroutine
This commit moves the `shouldBroadcast` logic closer to the execution logic of deciding whether we want to broadcast the announcements. This is a pure code refactor and should make no difference in announcing message unless the `d.syncMgr.IsGraphSynced()` gives different results inside the goroutine.
This commit is contained in:
1 file changed
+6
-10
+6
-10
@@ -1187,12 +1187,6 @@ func (d *AuthenticatedGossiper) networkHandler() {
|
|||||||
announcement.msg.MsgType(),
|
announcement.msg.MsgType(),
|
||||||
announcement.isRemote)
|
announcement.isRemote)
|
||||||
|
|
||||||
// We should only broadcast this message forward if it
|
|
||||||
// originated from us or it wasn't received as part of
|
|
||||||
// our initial historical sync.
|
|
||||||
shouldBroadcast := !announcement.isRemote ||
|
|
||||||
d.syncMgr.IsGraphSynced()
|
|
||||||
|
|
||||||
switch announcement.msg.(type) {
|
switch announcement.msg.(type) {
|
||||||
// Channel announcement signatures are amongst the only
|
// Channel announcement signatures are amongst the only
|
||||||
// messages that we'll process serially.
|
// messages that we'll process serially.
|
||||||
@@ -1232,8 +1226,7 @@ func (d *AuthenticatedGossiper) networkHandler() {
|
|||||||
|
|
||||||
d.wg.Add(1)
|
d.wg.Add(1)
|
||||||
go d.handleNetworkMessages(
|
go d.handleNetworkMessages(
|
||||||
announcement, &announcements,
|
announcement, &announcements, validationBarrier,
|
||||||
validationBarrier, shouldBroadcast,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// The trickle timer has ticked, which indicates we should
|
// The trickle timer has ticked, which indicates we should
|
||||||
@@ -1305,12 +1298,15 @@ func (d *AuthenticatedGossiper) networkHandler() {
|
|||||||
//
|
//
|
||||||
// NOTE: must be run as a goroutine.
|
// NOTE: must be run as a goroutine.
|
||||||
func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,
|
func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,
|
||||||
deDuped *deDupedAnnouncements, vb *routing.ValidationBarrier,
|
deDuped *deDupedAnnouncements, vb *routing.ValidationBarrier) {
|
||||||
shouldBroadcast bool) {
|
|
||||||
|
|
||||||
defer d.wg.Done()
|
defer d.wg.Done()
|
||||||
defer vb.CompleteJob()
|
defer vb.CompleteJob()
|
||||||
|
|
||||||
|
// We should only broadcast this message forward if it originated from
|
||||||
|
// us or it wasn't received as part of our initial historical sync.
|
||||||
|
shouldBroadcast := !nMsg.isRemote || d.syncMgr.IsGraphSynced()
|
||||||
|
|
||||||
// If this message has an existing dependency, then we'll wait until
|
// If this message has an existing dependency, then we'll wait until
|
||||||
// that has been fully validated before we proceed.
|
// that has been fully validated before we proceed.
|
||||||
err := vb.WaitForDependants(nMsg.msg)
|
err := vb.WaitForDependants(nMsg.msg)
|
||||||
|
|||||||
Reference in new issue
Block a user