File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -1076,13 +1076,26 @@ proc doPeerPause(
10761076 nanoseconds (nanos)
10771077 else :
10781078 1 .seconds
1079- peerFut = peer.getFuture ().join ()
10801079
1081- debug " Peer is entering sleeping state " , sleep_time = timeToSlot
1082- discard await race ( sleepAsync (timeToSlot), peerFut)
1083- if peerFut. finished () :
1080+ # Without this check peer.getFuture() could return absolutely new Future,
1081+ # which will never be finished, because peer is already disconnected.
1082+ if peer.connectionState != ConnectionState . Connected :
10841083 return false
10851084
1085+ let
1086+ peerFut = peer.getFuture ().join ()
1087+ timeFut = sleepAsync (timeToSlot)
1088+
1089+ try :
1090+ debug " Peer is entering sleeping state" , sleep_time = timeToSlot
1091+ discard await race (timeFut, peerFut)
1092+ if peerFut.finished ():
1093+ await cancelAndWait (timeFut)
1094+ return false
1095+ await cancelAndWait (peerFut)
1096+ except CancelledError as exc:
1097+ await cancelAndWait (timeFut, peerFut)
1098+ raise exc
10861099 true
10871100
10881101proc doPeerUpdateStatus (
You can’t perform that action at this time.
0 commit comments