erigon-pulse/cmd/observer/utils/sleep.go
battlmonstr 92db317e06
Observer - P2P network crawler (#3928)
Observer crawls the Ethereum network and collects information about the nodes.
2022-04-22 12:02:12 +01:00

16 lines
236 B
Go

package utils
import (
"context"
"time"
)
func Sleep(parentContext context.Context, timeout time.Duration) {
if timeout <= 0 {
return
}
ctx, cancel := context.WithTimeout(parentContext, timeout)
defer cancel()
<-ctx.Done()
}