add IP whitelist for colocation factor penalty

This commit is contained in:
vyzo 2020-03-27 20:21:42 +02:00
parent 68b86a4b66
commit ea7305245d
2 changed files with 6 additions and 0 deletions

View File

@ -228,6 +228,11 @@ func (ps *peerScore) score(p peer.ID) float64 {
// P6: IP collocation factor
for _, ip := range pstats.ips {
_, whitelisted := ps.params.IPColocationFactorWhitelist[ip]
if whitelisted {
continue
}
peersInIP := len(ps.peerIPs[ip])
if peersInIP > ps.params.IPColocationFactorThreshold {
surpluss := float64(peersInIP - ps.params.IPColocationFactorThreshold)

View File

@ -63,6 +63,7 @@ type PeerScoreParams struct {
// thus disabling the IP colocation penalty.
IPColocationFactorWeight float64
IPColocationFactorThreshold int
IPColocationFactorWhitelist map[string]struct{}
// the decay interval for parameter counters.
DecayInterval time.Duration