Skip to content

Commit

Permalink
(BIDS-2434) Refactored attesterSlot
Browse files Browse the repository at this point in the history
  • Loading branch information
Eisei24 committed Sep 5, 2023
1 parent 5d6cd41 commit 95e164e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions db/bigtable.go
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ func (bigtable *Bigtable) GetValidatorAttestationHistory(validators []uint64, st
}

maxSlot := (endEpoch + 1) * utils.Config.Chain.Config.SlotsPerEpoch
// map with structure attestationsMap[validator][attesterSlot]
attestationsMap := make(map[uint64]map[uint64][]*types.ValidatorAttestation)

// Save info for all inclusionSlot for attestations in attestationsMap
Expand Down Expand Up @@ -919,7 +920,6 @@ func (bigtable *Bigtable) GetValidatorAttestationHistory(validators []uint64, st
}

attestationsMap[validator][attesterSlot] = append(attestationsMap[validator][attesterSlot], &types.ValidatorAttestation{
AttesterSlot: attesterSlot,
InclusionSlot: inclusionSlot,
Status: status,
})
Expand Down Expand Up @@ -961,7 +961,7 @@ func (bigtable *Bigtable) GetValidatorAttestationHistory(validators []uint64, st
if res[validator] == nil {
res[validator] = make([]*types.ValidatorAttestation, 0)
}
for _, att := range attestations {
for attesterSlot, att := range attestations {
currentAttInfo := att[0]
for _, attInfo := range att {
if orphanedSlotsMap[attInfo.InclusionSlot] {
Expand All @@ -981,9 +981,10 @@ func (bigtable *Bigtable) GetValidatorAttestationHistory(validators []uint64, st
}
}
currentAttInfo.Index = validator
currentAttInfo.Epoch = currentAttInfo.AttesterSlot / utils.Config.Chain.Config.SlotsPerEpoch
currentAttInfo.Epoch = attesterSlot / utils.Config.Chain.Config.SlotsPerEpoch
currentAttInfo.CommitteeIndex = 0
currentAttInfo.Delay = int64(currentAttInfo.InclusionSlot - currentAttInfo.AttesterSlot - missedSlotsCount - 1)
currentAttInfo.AttesterSlot = attesterSlot
currentAttInfo.Delay = int64(currentAttInfo.InclusionSlot - attesterSlot - missedSlotsCount - 1)

res[validator] = append(res[validator], currentAttInfo)
}
Expand Down

0 comments on commit 95e164e

Please sign in to comment.