mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-31 16:21:21 +00:00
57bcbaa21f
* Correct naming of hash func in Eth2 * Customizable mode of operation for Caplin
31 lines
920 B
Go
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)
|
|
}
|