eth, p2p: reserve half peer slots for snap peers during snap sync (#22171)
* eth, p2p: reserve half peer slots for snap peers during snap sync * eth: less logging * eth: rework the eth/snap peer reservation logic * eth: rework the eth/snap peer reservation logic (again)
This commit is contained in:
committed by
GitHub
parent
adf130def8
commit
d2779ed7ac
10
p2p/peer.go
10
p2p/peer.go
@ -158,6 +158,16 @@ func (p *Peer) Caps() []Cap {
|
||||
return p.rw.caps
|
||||
}
|
||||
|
||||
// SupportsCap returns true if the peer supports the given protocol/version
|
||||
func (p *Peer) SupportsCap(protocol string, version uint) bool {
|
||||
for _, cap := range p.rw.caps {
|
||||
if cap.Name == protocol {
|
||||
return version <= cap.Version
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// RemoteAddr returns the remote address of the network connection.
|
||||
func (p *Peer) RemoteAddr() net.Addr {
|
||||
return p.rw.fd.RemoteAddr()
|
||||
|
Reference in New Issue
Block a user