mirror of
https://github.com/logos-messaging/go-libp2p-pubsub.git
synced 2026-01-04 13:53:06 +00:00
add IP whitelist for colocation factor penalty
This commit is contained in:
parent
68b86a4b66
commit
ea7305245d
5
score.go
5
score.go
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user