Skip to content

Commit

Permalink
to be reverted: remove peers filter
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Sep 22, 2024
1 parent 21d8e38 commit 50a74f5
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions p2p/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -827,28 +827,28 @@ func (sw *Switch) addOutboundPeerWithConfig(

func (sw *Switch) filterPeer(p Peer) error {
// Avoid duplicate
if sw.peers.Has(p.ID()) {
return ErrRejected{id: p.ID(), isDuplicate: true}
}

errc := make(chan error, len(sw.peerFilters))

for _, f := range sw.peerFilters {
go func(f PeerFilterFunc, p Peer, errc chan<- error) {
errc <- f(sw.peers, p)
}(f, p, errc)
}

for i := 0; i < cap(errc); i++ {
select {
case err := <-errc:
if err != nil {
return ErrRejected{id: p.ID(), err: err, isFiltered: true}
}
case <-time.After(sw.filterTimeout):
return ErrFilterTimeout{}
}
}
//if sw.peers.Has(p.ID()) {
// return ErrRejected{id: p.ID(), isDuplicate: true}
//}
//
//errc := make(chan error, len(sw.peerFilters))
//
//for _, f := range sw.peerFilters {
// go func(f PeerFilterFunc, p Peer, errc chan<- error) {
// errc <- f(sw.peers, p)
// }(f, p, errc)
//}
//
//for i := 0; i < cap(errc); i++ {
// select {
// case err := <-errc:
// if err != nil {
// return ErrRejected{id: p.ID(), err: err, isFiltered: true}
// }
// case <-time.After(sw.filterTimeout):
// return ErrFilterTimeout{}
// }
//}

return nil
}
Expand Down

0 comments on commit 50a74f5

Please sign in to comment.