erigon-pulse/cl/phase1/cache/attestation_indicies_cache.go
Giulio rebuffo 57bcbaa21f
Adds flags to enable/disable backfilling and enable full historical beacon node (#8813)
* Correct naming of hash func in Eth2
* Customizable mode of operation for Caplin
2023-11-22 13:24:35 +01:00

31 lines
920 B
Go

package cache
import (
"github.com/ledgerwatch/erigon-lib/common"
"github.com/ledgerwatch/erigon/cl/cltypes/solid"
"github.com/ledgerwatch/erigon/cl/phase1/core/state/lru"
"github.com/ledgerwatch/erigon/cl/utils"
)
var attestationIndiciesCache *lru.Cache[common.Hash, []uint64]
const attestationIndiciesCacheSize = 1024
func LoadAttestatingIndicies(attestation *solid.AttestationData, aggregationBits []byte) ([]uint64, bool) {
bitsHash := utils.Sha256(aggregationBits)
hash, err := attestation.HashSSZ()
if err != nil {
return nil, false
}
return attestationIndiciesCache.Get(utils.Sha256(hash[:], bitsHash[:]))
}
func StoreAttestation(attestation *solid.AttestationData, aggregationBits []byte, indicies []uint64) {
bitsHash := utils.Sha256(aggregationBits)
hash, err := attestation.HashSSZ()
if err != nil {
return
}
attestationIndiciesCache.Add(utils.Sha256(hash[:], bitsHash[:]), indicies)
}