@@ -1036,21 +1036,25 @@ func (gs *GossipSubRouter) Join(topic string) {
10361036
10371037	gmap , ok  =  gs .fanout [topic ]
10381038	if  ok  {
1039+ 		backoff  :=  gs .backoff [topic ]
10391040		// these peers have a score above the publish threshold, which may be negative 
10401041		// so drop the ones with a negative score 
10411042		for  p  :=  range  gmap  {
1042- 			if  gs .score .Score (p ) <  0  {
1043+ 			_ , doBackOff  :=  backoff [p ]
1044+ 			if  gs .score .Score (p ) <  0  ||  doBackOff  {
10431045				delete (gmap , p )
10441046			}
10451047		}
10461048
10471049		if  len (gmap ) <  gs .params .D  {
10481050			// we need more peers; eager, as this would get fixed in the next heartbeat 
10491051			more  :=  gs .getPeers (topic , gs .params .D - len (gmap ), func (p  peer.ID ) bool  {
1050- 				// filter our current peers, direct peers, and peers with negative scores 
1052+ 				// filter our current peers, direct peers, peers we are backing off, and 
1053+ 				// peers with negative scores 
10511054				_ , inMesh  :=  gmap [p ]
10521055				_ , direct  :=  gs .direct [p ]
1053- 				return  ! inMesh  &&  ! direct  &&  gs .score .Score (p ) >=  0 
1056+ 				_ , doBackOff  :=  backoff [p ]
1057+ 				return  ! inMesh  &&  ! direct  &&  ! doBackOff  &&  gs .score .Score (p ) >=  0 
10541058			})
10551059			for  _ , p  :=  range  more  {
10561060				gmap [p ] =  struct {}{}
@@ -1060,10 +1064,12 @@ func (gs *GossipSubRouter) Join(topic string) {
10601064		delete (gs .fanout , topic )
10611065		delete (gs .lastpub , topic )
10621066	} else  {
1067+ 		backoff  :=  gs .backoff [topic ]
10631068		peers  :=  gs .getPeers (topic , gs .params .D , func (p  peer.ID ) bool  {
1064- 			// filter direct peers and peers with negative score 
1069+ 			// filter direct peers, peers we are backing off  and peers with negative score 
10651070			_ , direct  :=  gs .direct [p ]
1066- 			return  ! direct  &&  gs .score .Score (p ) >=  0 
1071+ 			_ , doBackOff  :=  backoff [p ]
1072+ 			return  ! direct  &&  ! doBackOff  &&  gs .score .Score (p ) >=  0 
10671073		})
10681074		gmap  =  peerListToMap (peers )
10691075		gs .mesh [topic ] =  gmap 
0 commit comments