@@ -29,7 +29,6 @@ const (
2929 initialBackoffDelay = 10 * time .Second
3030 maxBackoffDelay = 5 * time .Minute
3131 backoffFactor = 2
32- DefaultMinPeersPerBin = 4
3332 DefaultDurPercentile = 0.4 // consider 40% as healthy, lower percentile = stricter duration check
3433 DefaultConnsPercentile = 0.8 // consider 80% as healthy, lower percentile = stricter conns check
3534)
@@ -64,7 +63,6 @@ func New(
6463 logger log.Logger ,
6564 startupStabilizer stabilization.Subscriber ,
6665 mode string ,
67- minPeersPerbin int ,
6866 durPercentile float64 ,
6967 connsPercentile float64 ,
7068) * service {
@@ -81,12 +79,12 @@ func New(
8179 }
8280
8381 s .wg .Add (1 )
84- go s .worker (startupStabilizer , mode , minPeersPerbin , durPercentile , connsPercentile )
82+ go s .worker (startupStabilizer , mode , durPercentile , connsPercentile )
8583
8684 return s
8785}
8886
89- func (s * service ) worker (startupStabilizer stabilization.Subscriber , mode string , minPeersPerbin int , durPercentile float64 , connsPercentile float64 ) {
87+ func (s * service ) worker (startupStabilizer stabilization.Subscriber , mode string , durPercentile float64 , connsPercentile float64 ) {
9088 defer s .wg .Done ()
9189
9290 sub , unsubscribe := startupStabilizer .Subscribe ()
@@ -102,7 +100,7 @@ func (s *service) worker(startupStabilizer stabilization.Subscriber, mode string
102100 currentDelay := initialBackoffDelay
103101
104102 for {
105- s .salud (mode , minPeersPerbin , durPercentile , connsPercentile )
103+ s .salud (mode , durPercentile , connsPercentile )
106104
107105 select {
108106 case <- s .quit :
@@ -134,13 +132,12 @@ type peer struct {
134132// salud acquires the status snapshot of every peer and computes an nth percentile of response duration and connected
135133// per count, the most common storage radius, and the batch commitment, and based on these values, marks peers as unhealhy that fall beyond
136134// the allowed thresholds.
137- func (s * service ) salud (mode string , minPeersPerbin int , durPercentile float64 , connsPercentile float64 ) {
135+ func (s * service ) salud (mode string , durPercentile float64 , connsPercentile float64 ) {
138136 var (
139137 mtx sync.Mutex
140138 wg sync.WaitGroup
141139 totaldur float64
142140 peers []peer
143- bins [swarm .MaxBins ]int
144141 )
145142
146143 err := s .topology .EachConnectedPeer (func (addr swarm.Address , bin uint8 ) (stop bool , jumpToNext bool , err error ) {
@@ -165,7 +162,6 @@ func (s *service) salud(mode string, minPeersPerbin int, durPercentile float64,
165162 }
166163
167164 mtx .Lock ()
168- bins [bin ]++
169165 totaldur += dur .Seconds ()
170166 peers = append (peers , peer {snapshot , dur , addr , bin , s .reserve .IsWithinStorageRadius (addr )})
171167 mtx .Unlock ()
@@ -206,17 +202,10 @@ func (s *service) salud(mode string, minPeersPerbin int, durPercentile float64,
206202
207203 var healthy bool
208204
209- // every bin should have at least some peers, healthy or not
210- if bins [peer .bin ] <= minPeersPerbin {
211- s .metrics .Healthy .Inc ()
212- s .topology .UpdatePeerHealth (peer .addr , true , peer .dur )
213- continue
214- }
215-
216205 if networkRadius > 0 && peer .status .CommittedDepth < uint32 (networkRadius - 2 ) {
217206 s .logger .Debug ("radius health failure" , "radius" , peer .status .CommittedDepth , "peer_address" , peer .addr , "bin" , peer .bin )
218207 } else if peer .dur .Seconds () > pDur {
219- s .logger .Debug ("response duration below threshold" , "duration" , peer .dur , "peer_address" , peer .addr , "bin" , peer .bin )
208+ s .logger .Debug ("response duration above threshold" , "duration" , peer .dur , "peer_address" , peer .addr , "bin" , peer .bin )
220209 } else if peer .status .ConnectedPeers < pConns {
221210 s .logger .Debug ("connections count below threshold" , "connections" , peer .status .ConnectedPeers , "peer_address" , peer .addr , "bin" , peer .bin )
222211 } else if peer .status .BatchCommitment != commitment {
@@ -230,7 +219,6 @@ func (s *service) salud(mode string, minPeersPerbin int, durPercentile float64,
230219 s .metrics .Healthy .Inc ()
231220 } else {
232221 s .metrics .Unhealthy .Inc ()
233- bins [peer .bin ]--
234222 }
235223 }
236224
0 commit comments