Skip to content

Commit 5a1bca3

Browse files
tarakbypeterargue
andauthored
use Throw to bubble the error up
Co-authored-by: Peter Argue <[email protected]>
1 parent 908212f commit 5a1bca3

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

network/p2p/connection/peerManager.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,10 @@ func (pm *PeerManager) updateLoop(ctx irrecoverable.SignalerContext) {
8686
func (pm *PeerManager) periodicLoop(ctx irrecoverable.SignalerContext) {
8787
// add a random delay to initial launch to avoid synchronizing this
8888
// potentially expensive operation across the network
89-
r, _ := rand.Uint64n(uint64(pm.peerUpdateInterval.Nanoseconds()))
90-
// ignore the error here, if randomness fails `r` would be zero and there will be no delay
91-
// for the current node
92-
// TODO: treat the error properly instead of swallowing it. In this specific case, `utils/rand`
93-
// only errors if there is a randomness system issue. Such issue will cause errors in many
94-
// other components.
89+
r, err := rand.Uint64n(uint64(pm.peerUpdateInterval.Nanoseconds()))
90+
if err != nil {
91+
ctx.Throw(fmt.Errorf("unable to generate random interval: %w", err))
92+
}
9593
delay := time.Duration(r)
9694

9795
ticker := time.NewTicker(pm.peerUpdateInterval)

0 commit comments

Comments
 (0)