descore when opening connection fails, same as when reading fails (#6130)
`eth2_network` forgets to descore peers when opening connection times out. It only descores when opening the connection succeeds and then there is a subsequent error. The caller cannot distinguish the cases, so ensure that the descore is also applied if the request fails during its initial portion.
This commit is contained in:
parent
3765e8ac06
commit
991e7cafbc
|
@ -971,8 +971,14 @@ proc makeEth2Request(peer: Peer, protocolId: string, requestBytes: seq[byte],
|
|||
deadline = sleepAsync timeout
|
||||
streamRes =
|
||||
awaitWithTimeout(peer.network.openStream(peer, protocolId), deadline):
|
||||
peer.updateScore(PeerScorePoorRequest)
|
||||
return neterr StreamOpenTimeout
|
||||
stream = ?streamRes
|
||||
stream = streamRes.valueOr:
|
||||
if streamRes.error().kind in ProtocolViolations:
|
||||
peer.updateScore(PeerScoreInvalidRequest)
|
||||
else:
|
||||
peer.updateScore(PeerScorePoorRequest)
|
||||
return err streamRes.error()
|
||||
|
||||
try:
|
||||
# Send the request
|
||||
|
|
Loading…
Reference in New Issue