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 b96a52b
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 @@ -48,6 +48,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 = transition.ProcessSlotsUsingNextSlotCache(ctx, st, c.Root, slot)
if err != nil {
return nil
Expand Down

0 comments on commit b96a52b

Please sign in to comment.