Remove the internal goroutine and call the function using 'go'
211
212// PruneBlobsBundleCacheRoutine prunes the blobs bundle cache at 6s mark of the slot.
213func (vs *Server) PruneBlobsBundleCacheRoutine() {
214 go func() {215 clock, err := vs.ClockWaiter.WaitForClock(vs.Ctx)
216 if err != nil {
217 log.WithError(err).Error("PruneBlobsBundleCacheRoutine failed to receive genesis data")
Description
Function invocations are expected to be synchronous, but this function will execute asynchronously because every instruction of the function is executed in a goroutine. Instead, it is recommended to remove the internal goroutine and call the function using 'go'.
Bad practice
func hello() {
go func() {
fmt.Println("hello world")
}()
}
func world() {
hello()
...
}
Recommended
func hello() {
fmt.Println("hello world")
}
func world() {
go hello()
...
}