Skip to content

Commit

Permalink
acquire a multilock
Browse files Browse the repository at this point in the history
  • Loading branch information
potuz committed Mar 16, 2024
1 parent 0ddbdfe commit 7d1d045
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions beacon-chain/blockchain/process_attestation_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ func (s *Service) getRecentPreState(ctx context.Context, c *ethpb.Checkpoint) st
if err != nil {
return nil
}
// Try if we have already set the checkpoint cache
epochKey := strconv.FormatUint(uint64(c.Epoch), 10 /* base 10 */)
lock := async.NewMultilock(string(c.Root) + epochKey)
lock.Lock()
defer lock.Unlock()
cachedState, err := s.checkpointStateCache.StateByCheckpoint(c)
if err != nil {
return nil
}
if cachedState != nil && !cachedState.IsNil() {
return cachedState
}
st, err := s.HeadState(ctx)
if err != nil {
return nil
Expand Down

0 comments on commit 7d1d045

Please sign in to comment.