@@ -517,6 +517,9 @@ type AuthenticatedGossiper struct {
517
517
// AuthenticatedGossiper lock.
518
518
chanUpdateRateLimiter map [uint64 ][2 ]* rate.Limiter
519
519
520
+ // vb is used to enforce job dependency ordering of gossip messages.
521
+ vb * graph.ValidationBarrier
522
+
520
523
sync.Mutex
521
524
}
522
525
@@ -542,6 +545,8 @@ func New(cfg Config, selfKeyDesc *keychain.KeyDescriptor) *AuthenticatedGossiper
542
545
banman : newBanman (),
543
546
}
544
547
548
+ gossiper .vb = graph .NewValidationBarrier (1000 , gossiper .quit )
549
+
545
550
gossiper .syncMgr = newSyncManager (& SyncManagerCfg {
546
551
ChainHash : cfg .ChainHash ,
547
552
ChanSeries : cfg .ChanSeries ,
@@ -1409,10 +1414,6 @@ func (d *AuthenticatedGossiper) networkHandler() {
1409
1414
log .Errorf ("Unable to rebroadcast stale announcements: %v" , err )
1410
1415
}
1411
1416
1412
- // We'll use this validation to ensure that we process jobs in their
1413
- // dependency order during parallel validation.
1414
- validationBarrier := graph .NewValidationBarrier (1000 , d .quit )
1415
-
1416
1417
for {
1417
1418
select {
1418
1419
// A new policy update has arrived. We'll commit it to the
@@ -1481,11 +1482,17 @@ func (d *AuthenticatedGossiper) networkHandler() {
1481
1482
// We'll set up any dependent, and wait until a free
1482
1483
// slot for this job opens up, this allow us to not
1483
1484
// have thousands of goroutines active.
1484
- validationBarrier .InitJobDependencies (announcement .msg )
1485
+ annJobID , err := d .vb .InitJobDependencies (
1486
+ announcement .msg ,
1487
+ )
1488
+ if err != nil {
1489
+ announcement .err <- err
1490
+ continue
1491
+ }
1485
1492
1486
1493
d .wg .Add (1 )
1487
1494
go d .handleNetworkMessages (
1488
- announcement , & announcements , validationBarrier ,
1495
+ announcement , & announcements , annJobID ,
1489
1496
)
1490
1497
1491
1498
// The trickle timer has ticked, which indicates we should
@@ -1536,18 +1543,18 @@ func (d *AuthenticatedGossiper) networkHandler() {
1536
1543
//
1537
1544
// NOTE: must be run as a goroutine.
1538
1545
func (d * AuthenticatedGossiper ) handleNetworkMessages (nMsg * networkMsg ,
1539
- deDuped * deDupedAnnouncements , vb * graph.ValidationBarrier ) {
1546
+ deDuped * deDupedAnnouncements , jobID graph.JobID ) {
1540
1547
1541
1548
defer d .wg .Done ()
1542
- defer vb .CompleteJob ()
1549
+ defer d . vb .CompleteJob ()
1543
1550
1544
1551
// We should only broadcast this message forward if it originated from
1545
1552
// us or it wasn't received as part of our initial historical sync.
1546
1553
shouldBroadcast := ! nMsg .isRemote || d .syncMgr .IsGraphSynced ()
1547
1554
1548
1555
// If this message has an existing dependency, then we'll wait until
1549
1556
// that has been fully validated before we proceed.
1550
- err := vb .WaitForDependants ( nMsg .msg )
1557
+ err := d . vb .WaitForParents ( jobID , nMsg .msg )
1551
1558
if err != nil {
1552
1559
log .Debugf ("Validating network message %s got err: %v" ,
1553
1560
nMsg .msg .MsgType (), err )
@@ -1577,7 +1584,16 @@ func (d *AuthenticatedGossiper) handleNetworkMessages(nMsg *networkMsg,
1577
1584
1578
1585
// If this message had any dependencies, then we can now signal them to
1579
1586
// continue.
1580
- vb .SignalDependants (nMsg .msg , allow )
1587
+ err = d .vb .SignalDependents (nMsg .msg , jobID )
1588
+ if err != nil {
1589
+ // Something is wrong if SignalDependents returns an error.
1590
+ log .Errorf ("SignalDependents returned error for msg=%v with " +
1591
+ "JobID=%v" , spew .Sdump (nMsg .msg ), jobID )
1592
+
1593
+ nMsg .err <- err
1594
+
1595
+ return
1596
+ }
1581
1597
1582
1598
// If the announcement was accepted, then add the emitted announcements
1583
1599
// to our announce batch to be broadcast once the trickle timer ticks
0 commit comments