Skip to content

Commit

Permalink
Merge branch 'master' into pk910/per-validator-operations
Browse files Browse the repository at this point in the history
  • Loading branch information
pk910 committed Nov 29, 2024
2 parents 1c12140 + d0e0fd2 commit ea5f105
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions indexer/beacon/epochvotes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
type epochVotesKey [32 + 8 + 32 + 1]byte

// generate epochStatsKey from epoch and dependentRoot
func getEpochVotesKey(epoch phase0.Epoch, dependentRoot phase0.Root, highestRoot phase0.Root, blockCount uint8, hasValues bool) epochVotesKey {
func getEpochVotesKey(epoch phase0.Epoch, dependentRoot phase0.Root, highestRoot phase0.Root, blockCount uint8, hasValues bool, isPrecalc bool) epochVotesKey {
var key epochVotesKey

copy(key[0:], dependentRoot[:])
Expand All @@ -26,6 +26,9 @@ func getEpochVotesKey(epoch phase0.Epoch, dependentRoot phase0.Root, highestRoot
if hasValues {
key[72] |= 0x80
}
if isPrecalc {
key[72] |= 0x40
}

return key
}
Expand Down Expand Up @@ -69,8 +72,9 @@ func (indexer *Indexer) aggregateEpochVotes(epoch phase0.Epoch, chainState *cons
}

votesWithValues := epochStats != nil && epochStats.ready
votesWithPrecalc := epochStats != nil && epochStats.precalcValues != nil

votesKey := getEpochVotesKey(epoch, targetRoot, blocks[len(blocks)-1].Root, uint8(len(blocks)), votesWithValues)
votesKey := getEpochVotesKey(epoch, targetRoot, blocks[len(blocks)-1].Root, uint8(len(blocks)), votesWithValues, votesWithPrecalc)
if cachedVotes, isOk := indexer.epochCache.votesCache.Get(votesKey); isOk {
indexer.epochCache.votesCacheHit++
return cachedVotes
Expand Down

0 comments on commit ea5f105

Please sign in to comment.