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:
Martin Holst Swende
2021-01-25 19:06:52 +01:00
committed by GitHub
parent adf130def8
commit d2779ed7ac
4 changed files with 37 additions and 3 deletions

View File

@ -259,7 +259,7 @@ func (ps *peerSet) ethPeersWithoutTransaction(hash common.Hash) []*ethPeer {
}
// Len returns if the current number of `eth` peers in the set. Since the `snap`
// peers are tied to the existnce of an `eth` connection, that will always be a
// peers are tied to the existence of an `eth` connection, that will always be a
// subset of `eth`.
func (ps *peerSet) Len() int {
ps.lock.RLock()
@ -268,6 +268,15 @@ func (ps *peerSet) Len() int {
return len(ps.ethPeers)
}
// SnapLen returns if the current number of `snap` peers in the set. Since the `snap`
// peers are tied to the existence of an `eth` connection, that will always be a
// subset of `eth`.
func (ps *peerSet) SnapLen() int {
ps.lock.RLock()
defer ps.lock.RUnlock()
return len(ps.snapPeers)
}
// ethPeerWithHighestTD retrieves the known peer with the currently highest total
// difficulty.
func (ps *peerSet) ethPeerWithHighestTD() *eth.Peer {