mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-08 23:18:15 -05:00
Add context deadline for pending queue's receive block (#13114)
* Add context dead like for pending queue's receive block * Use timeout
This commit is contained in:
@@ -205,7 +205,12 @@ func (s *Service) processAndBroadcastBlock(ctx context.Context, b interfaces.Rea
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.cfg.chain.ReceiveBlock(ctx, b, blkRoot); err != nil {
|
||||
// Calculate the deadline time by adding two slots duration to the current time
|
||||
secondsPerSlot := params.BeaconConfig().SecondsPerSlot
|
||||
twoSlotDuration := 2 * time.Duration(secondsPerSlot) * time.Second
|
||||
ctxWithTimeout, cancelFunction := context.WithTimeout(ctx, twoSlotDuration)
|
||||
defer cancelFunction()
|
||||
if err := s.cfg.chain.ReceiveBlock(ctxWithTimeout, b, blkRoot); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user