Skip to content

Commit efcaf45

Browse files
committed
further simplify
1 parent 1b3ab73 commit efcaf45

File tree

1 file changed

+17
-21
lines changed

1 file changed

+17
-21
lines changed

network/wsNetwork.go

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,30 +1186,26 @@ func (wn *WebsocketNetwork) maybeSendMessagesOfInterest(peer *wsPeer, messagesOf
11861186
messagesOfInterestGeneration := wn.messagesOfInterestGeneration.Load()
11871187
peerMessagesOfInterestGeneration := peer.messagesOfInterestGeneration.Load()
11881188
if peerMessagesOfInterestGeneration != messagesOfInterestGeneration {
1189-
peerSupportsStatefulCompression := peer.vpackStatefulCompressionSupported()
1190-
sendEnc := messagesOfInterestEnc
1191-
var perPeerTags map[protocol.Tag]bool
1192-
if sendEnc == nil || !peerSupportsStatefulCompression {
1193-
wn.messagesOfInterestMu.Lock()
1194-
if sendEnc == nil {
1195-
sendEnc = wn.messagesOfInterestEnc
1196-
}
1197-
if !peerSupportsStatefulCompression && wn.messagesOfInterest[protocol.VotePackedTag] {
1198-
// Filter VP tag for peers lacking stateful compression support; older nodes (<= v4.3)
1199-
// treat unknown tags as protocol violations and disconnect.
1200-
perPeerTags = make(map[protocol.Tag]bool, len(wn.messagesOfInterest))
1201-
for tag, flag := range wn.messagesOfInterest {
1202-
if tag == protocol.VotePackedTag {
1203-
continue
1204-
}
1205-
perPeerTags[tag] = flag
1189+
wn.messagesOfInterestMu.Lock()
1190+
if messagesOfInterestEnc == nil {
1191+
messagesOfInterestEnc = wn.messagesOfInterestEnc
1192+
}
1193+
if !peer.vpackStatefulCompressionSupported() && wn.messagesOfInterest[protocol.VotePackedTag] {
1194+
// filter VP tag for peers lacking stateful compression support
1195+
// older nodes (<= v4.3) treat unknown tags as protocol violations and disconnect.
1196+
perPeerTags := make(map[protocol.Tag]bool, len(wn.messagesOfInterest))
1197+
for tag, flag := range wn.messagesOfInterest {
1198+
if tag == protocol.VotePackedTag {
1199+
continue
12061200
}
1207-
sendEnc = marshallMessageOfInterestMap(perPeerTags)
1201+
perPeerTags[tag] = flag
12081202
}
1209-
wn.messagesOfInterestMu.Unlock()
1203+
messagesOfInterestEnc = marshallMessageOfInterestMap(perPeerTags)
12101204
}
1211-
if sendEnc != nil {
1212-
peer.sendMessagesOfInterest(messagesOfInterestGeneration, sendEnc)
1205+
wn.messagesOfInterestMu.Unlock()
1206+
1207+
if messagesOfInterestEnc != nil {
1208+
peer.sendMessagesOfInterest(messagesOfInterestGeneration, messagesOfInterestEnc)
12131209
} else {
12141210
wn.log.Infof("msgOfInterest Enc=nil, MOIGen=%d", messagesOfInterestGeneration)
12151211
}

0 commit comments

Comments
 (0)