Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log peers rejected for diversity #759

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion rt_diversity_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@ import (

"github.com/libp2p/go-libp2p-kbucket/peerdiversity"

logging "github.com/ipfs/go-log"
ma "github.com/multiformats/go-multiaddr"
)

var dfLog = logging.Logger("dht/RtDiversityFilter")

var _ peerdiversity.PeerIPGroupFilter = (*rtPeerIPGroupFilter)(nil)

type rtPeerIPGroupFilter struct {
Expand Down Expand Up @@ -48,12 +51,15 @@ func (r *rtPeerIPGroupFilter) Allow(g peerdiversity.PeerGroupInfo) bool {
cpl := g.Cpl

if r.tableIpGroupCount[key] >= r.maxForTable {

dfLog.Debugw("rejecting (max for table) diversity", "peer', g.Id, "cpl", g.Cpl, "ip group", g.IPGroupKey)
return false
}

c, ok := r.cplIpGroupCount[cpl]
allow := !ok || c[key] < r.maxPerCpl
if !allow {
dfLog.Debugw("rejecting (max for cpl) diversity", "peer", g.Id, "cpl", g.Cpl, "ip group", g.IPGroupKey)
}
return allow
}

Expand Down