Skip to content

Commit 898c081

Browse files
Merge branch 'rel/beta' into relstable3.7.2
2 parents f945a21 + ccb2ec3 commit 898c081

File tree

3 files changed

+132
-92
lines changed

3 files changed

+132
-92
lines changed

buildnumber.dat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1
1+
2

network/wsNetwork.go

+22-20
Original file line numberDiff line numberDiff line change
@@ -417,8 +417,8 @@ type WebsocketNetwork struct {
417417
// messagesOfInterestMu protects messagesOfInterest and ensures
418418
// that messagesOfInterestEnc does not change once it is set during
419419
// network start.
420-
messagesOfInterestMu deadlock.Mutex
421-
messagesOfInterestCond *sync.Cond
420+
messagesOfInterestMu deadlock.Mutex
421+
messagesOfInterestRefresh chan struct{}
422422

423423
// peersConnectivityCheckTicker is the timer for testing that all the connected peers
424424
// are still transmitting or receiving information. The channel produced by this ticker
@@ -764,7 +764,7 @@ func (wn *WebsocketNetwork) setup() {
764764
SupportedProtocolVersions = []string{wn.config.NetworkProtocolVersion}
765765
}
766766

767-
wn.messagesOfInterestCond = sync.NewCond(&wn.messagesOfInterestMu)
767+
wn.messagesOfInterestRefresh = make(chan struct{}, 2)
768768
wn.messagesOfInterestGeneration = 1 // something nonzero so that any new wsPeer needs updating
769769
if wn.relayMessages {
770770
wn.RegisterMessageInterest(protocol.CompactCertSigTag)
@@ -1178,7 +1178,7 @@ func (wn *WebsocketNetwork) maybeSendMessagesOfInterest(peer *wsPeer, messagesOf
11781178
if messagesOfInterestEnc != nil {
11791179
peer.sendMessagesOfInterest(messagesOfInterestGeneration, messagesOfInterestEnc)
11801180
} else {
1181-
wn.log.Infof("msgOfInterest Enc=nil")
1181+
wn.log.Infof("msgOfInterest Enc=nil, MOIGen=%d", messagesOfInterestGeneration)
11821182
}
11831183
}
11841184
}
@@ -1726,14 +1726,10 @@ func (wn *WebsocketNetwork) OnNetworkAdvance() {
17261726
defer wn.lastNetworkAdvanceMu.Unlock()
17271727
wn.lastNetworkAdvance = time.Now().UTC()
17281728
if wn.nodeInfo != nil && !wn.relayMessages && !wn.config.ForceFetchTransactions {
1729-
// if we're not a relay, and not participating, we don't need txn pool
1730-
wantTXGossip := wn.nodeInfo.IsParticipating()
1731-
if wantTXGossip && (wn.wantTXGossip != wantTXGossipYes) {
1732-
wn.RegisterMessageInterest(protocol.TxnTag)
1733-
wn.wantTXGossip = wantTXGossipYes
1734-
} else if !wantTXGossip && (wn.wantTXGossip != wantTXGossipNo) {
1735-
wn.DeregisterMessageInterest(protocol.TxnTag)
1736-
wn.wantTXGossip = wantTXGossipNo
1729+
select {
1730+
case wn.messagesOfInterestRefresh <- struct{}{}:
1731+
default:
1732+
// if the notify chan is full, it will get around to updating the latest when it actually runs
17371733
}
17381734
}
17391735
}
@@ -2350,18 +2346,24 @@ func (wn *WebsocketNetwork) updateMessagesOfInterestEnc() {
23502346
wn.messagesOfInterestEnc = MarshallMessageOfInterestMap(wn.messagesOfInterest)
23512347
wn.messagesOfInterestEncoded = true
23522348
atomic.AddUint32(&wn.messagesOfInterestGeneration, 1)
2353-
wn.messagesOfInterestCond.Broadcast()
2349+
var peers []*wsPeer
2350+
peers, _ = wn.peerSnapshot(peers)
2351+
for _, peer := range peers {
2352+
wn.maybeSendMessagesOfInterest(peer, wn.messagesOfInterestEnc)
2353+
}
23542354
}
23552355

23562356
func (wn *WebsocketNetwork) postMessagesOfInterestThread() {
2357-
var peers []*wsPeer
2358-
wn.messagesOfInterestMu.Lock()
2359-
defer wn.messagesOfInterestMu.Unlock()
23602357
for {
2361-
wn.messagesOfInterestCond.Wait()
2362-
peers, _ = wn.peerSnapshot(peers)
2363-
for _, peer := range peers {
2364-
wn.maybeSendMessagesOfInterest(peer, wn.messagesOfInterestEnc)
2358+
<-wn.messagesOfInterestRefresh
2359+
// if we're not a relay, and not participating, we don't need txn pool
2360+
wantTXGossip := wn.nodeInfo.IsParticipating()
2361+
if wantTXGossip && (wn.wantTXGossip != wantTXGossipYes) {
2362+
wn.RegisterMessageInterest(protocol.TxnTag)
2363+
atomic.StoreUint32(&wn.wantTXGossip, wantTXGossipYes)
2364+
} else if !wantTXGossip && (wn.wantTXGossip != wantTXGossipNo) {
2365+
wn.DeregisterMessageInterest(protocol.TxnTag)
2366+
atomic.StoreUint32(&wn.wantTXGossip, wantTXGossipNo)
23652367
}
23662368
}
23672369
}

0 commit comments

Comments
 (0)