File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -2036,6 +2036,20 @@ export class GossipSub extends TypedEventEmitter<GossipsubEvents> implements Pub
2036
2036
tosend . add ( peer )
2037
2037
tosendCount . mesh ++
2038
2038
} )
2039
+
2040
+ // We want to publish to at least `D` peers.
2041
+ // If there are insufficient peers in the mesh, publish to other topic peers
2042
+ if ( meshPeers . size < this . opts . D ) {
2043
+ // pick additional topic peers above the publishThreshold
2044
+ const topicPeers = this . getRandomGossipPeers ( topic , this . opts . D - meshPeers . size , ( id ) => {
2045
+ return ! meshPeers . has ( id ) && ! this . direct . has ( id ) && ! this . floodsubPeers . has ( id ) && this . score . score ( id ) >= this . opts . scoreThresholds . publishThreshold
2046
+ } )
2047
+
2048
+ topicPeers . forEach ( ( peer ) => {
2049
+ tosend . add ( peer )
2050
+ tosendCount . mesh ++
2051
+ } )
2052
+ }
2039
2053
// eslint-disable-next-line @typescript-eslint/brace-style
2040
2054
}
2041
2055
You can’t perform that action at this time.
0 commit comments