Skip to content

Commit

Permalink
prevent duplicate processing of epochstats
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Aug 17, 2024
1 parent 6ec4207 commit 82638d8
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions indexer/beacon/epochstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ type EpochStats struct {
dependentRoot phase0.Root
dependentState *epochState

requestedMutex sync.Mutex
requestedBy []*Client
ready bool
readyChanMutex sync.Mutex
readyChan chan bool
isInDb bool
requestedMutex sync.Mutex
requestedBy []*Client
ready bool
readyChanMutex sync.Mutex
readyChan chan bool
processingMutex sync.Mutex
processing bool
isInDb bool

precalcBaseRoot phase0.Root
precalcValues *EpochStatsValues
Expand Down Expand Up @@ -305,6 +307,20 @@ func (es *EpochStats) processState(indexer *Indexer) {
if es.dependentState == nil || es.dependentState.loadingStatus != 2 {
return
}

es.processingMutex.Lock()
if es.processing {
es.processingMutex.Unlock()
return
}

es.processing = true
es.processingMutex.Unlock()

defer func() {
es.processing = false
}()

t1 := time.Now()

chainState := indexer.consensusPool.GetChainState()
Expand Down

0 comments on commit 82638d8

Please sign in to comment.