mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Use State Instead of Cached Registry (#2372)
* fix state reads * add method to retrieve validator from state * lint * batch update attestation * handle nil case * add test * lint * batch update attestation * use state instead * fix test
This commit is contained in:
parent
54f6fffb58
commit
941810ee7b
@ -95,12 +95,17 @@ func (a *Service) IncomingAttestationFeed() *event.Feed {
|
||||
// Attestation` be the attestation with the highest slot number in `store`
|
||||
// from the validator with the given `validator_index`
|
||||
func (a *Service) LatestAttestation(ctx context.Context, index uint64) (*pb.Attestation, error) {
|
||||
validator, err := a.beaconDB.ValidatorFromState(ctx, index)
|
||||
bState, err := a.beaconDB.HeadState(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pubKey := bytesutil.ToBytes48(validator.Pubkey)
|
||||
// return error if it's an invalid validator index.
|
||||
if index >= uint64(len(bState.ValidatorRegistry)) {
|
||||
return nil, fmt.Errorf("invalid validator index %d", index)
|
||||
}
|
||||
|
||||
pubKey := bytesutil.ToBytes48(bState.ValidatorRegistry[index].Pubkey)
|
||||
a.store.RLock()
|
||||
defer a.store.RUnlock()
|
||||
if _, exists := a.store.m[pubKey]; !exists {
|
||||
|
Loading…
Reference in New Issue
Block a user