2021-11-22 17:37:55 +00:00
|
|
|
package v3
|
|
|
|
|
|
|
|
// CurrentEpochParticipation corresponding to participation bits on the beacon chain.
|
|
|
|
func (b *BeaconState) CurrentEpochParticipation() ([]byte, error) {
|
|
|
|
if !b.hasInnerState() {
|
2022-05-17 09:38:35 +00:00
|
|
|
return nil, ErrNilInnerState
|
2021-11-22 17:37:55 +00:00
|
|
|
}
|
|
|
|
if b.state.CurrentEpochParticipation == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
b.lock.RLock()
|
|
|
|
defer b.lock.RUnlock()
|
|
|
|
|
|
|
|
return b.currentEpochParticipation(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// PreviousEpochParticipation corresponding to participation bits on the beacon chain.
|
|
|
|
func (b *BeaconState) PreviousEpochParticipation() ([]byte, error) {
|
|
|
|
if !b.hasInnerState() {
|
2022-05-17 09:38:35 +00:00
|
|
|
return nil, ErrNilInnerState
|
2021-11-22 17:37:55 +00:00
|
|
|
}
|
|
|
|
if b.state.PreviousEpochParticipation == nil {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
b.lock.RLock()
|
|
|
|
defer b.lock.RUnlock()
|
|
|
|
|
|
|
|
return b.previousEpochParticipation(), nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// currentEpochParticipation corresponding to participation bits on the beacon chain.
|
|
|
|
// This assumes that a lock is already held on BeaconState.
|
|
|
|
func (b *BeaconState) currentEpochParticipation() []byte {
|
|
|
|
if !b.hasInnerState() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
tmp := make([]byte, len(b.state.CurrentEpochParticipation))
|
|
|
|
copy(tmp, b.state.CurrentEpochParticipation)
|
|
|
|
return tmp
|
|
|
|
}
|
|
|
|
|
|
|
|
// previousEpochParticipation corresponding to participation bits on the beacon chain.
|
|
|
|
// This assumes that a lock is already held on BeaconState.
|
|
|
|
func (b *BeaconState) previousEpochParticipation() []byte {
|
|
|
|
if !b.hasInnerState() {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
tmp := make([]byte, len(b.state.PreviousEpochParticipation))
|
|
|
|
copy(tmp, b.state.PreviousEpochParticipation)
|
|
|
|
return tmp
|
|
|
|
}
|