prysm-pulse/beacon-chain/state/state-native/v1/getters_attestation.go

42 lines
1.3 KiB
Go
Raw Normal View History

package v1
import (
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
)
// PreviousEpochAttestations corresponding to blocks on the beacon chain.
func (b *BeaconState) PreviousEpochAttestations() ([]*ethpb.PendingAttestation, error) {
2022-01-24 10:24:38 +00:00
if b.previousEpochAttestations == nil {
return nil, nil
}
b.lock.RLock()
defer b.lock.RUnlock()
2022-01-24 10:24:38 +00:00
return b.previousEpochAttestationsVal(), nil
}
2022-01-24 10:24:38 +00:00
// previousEpochAttestationsVal corresponding to blocks on the beacon chain.
// This assumes that a lock is already held on BeaconState.
2022-01-24 10:24:38 +00:00
func (b *BeaconState) previousEpochAttestationsVal() []*ethpb.PendingAttestation {
return ethpb.CopyPendingAttestationSlice(b.previousEpochAttestations)
}
// CurrentEpochAttestations corresponding to blocks on the beacon chain.
func (b *BeaconState) CurrentEpochAttestations() ([]*ethpb.PendingAttestation, error) {
2022-01-24 10:24:38 +00:00
if b.currentEpochAttestations == nil {
return nil, nil
}
b.lock.RLock()
defer b.lock.RUnlock()
2022-01-24 10:24:38 +00:00
return b.currentEpochAttestationsVal(), nil
}
// currentEpochAttestations corresponding to blocks on the beacon chain.
// This assumes that a lock is already held on BeaconState.
2022-01-24 10:24:38 +00:00
func (b *BeaconState) currentEpochAttestationsVal() []*ethpb.PendingAttestation {
return ethpb.CopyPendingAttestationSlice(b.currentEpochAttestations)
}