mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-03-02 23:20:39 +00:00
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
|
deadline = sleepAsync timeout
|
||||||
streamRes =
|
streamRes =
|
||||||
awaitWithTimeout(peer.network.openStream(peer, protocolId), deadline):
|
awaitWithTimeout(peer.network.openStream(peer, protocolId), deadline):
|
||||||
|
peer.updateScore(PeerScorePoorRequest)
|
||||||
return neterr StreamOpenTimeout
|
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:
|
try:
|
||||||
# Send the request
|
# Send the request
|
||||||
|
Loading…
x
Reference in New Issue
Block a user