2022-01-13 11:23:53 +00:00
|
|
|
package v2
|
|
|
|
|
|
|
|
// CurrentEpochParticipation corresponding to participation bits on the beacon chain.
|
|
|
|
func (b *BeaconState) CurrentEpochParticipation() ([]byte, error) {
|
2022-01-27 08:42:32 +00:00
|
|
|
if b.currentEpochParticipation == nil {
|
2022-01-13 11:23:53 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
b.lock.RLock()
|
|
|
|
defer b.lock.RUnlock()
|
|
|
|
|
2022-01-27 08:42:32 +00:00
|
|
|
return b.currentEpochParticipationVal(), nil
|
2022-01-13 11:23:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PreviousEpochParticipation corresponding to participation bits on the beacon chain.
|
|
|
|
func (b *BeaconState) PreviousEpochParticipation() ([]byte, error) {
|
2022-01-27 08:42:32 +00:00
|
|
|
if b.previousEpochParticipation == nil {
|
2022-01-13 11:23:53 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
b.lock.RLock()
|
|
|
|
defer b.lock.RUnlock()
|
|
|
|
|
2022-01-27 08:42:32 +00:00
|
|
|
return b.previousEpochParticipationVal(), nil
|
2022-01-13 11:23:53 +00:00
|
|
|
}
|
|
|
|
|
2022-01-27 08:42:32 +00:00
|
|
|
// currentEpochParticipationVal corresponding to participation bits on the beacon chain.
|
2022-01-13 11:23:53 +00:00
|
|
|
// This assumes that a lock is already held on BeaconState.
|
2022-01-27 08:42:32 +00:00
|
|
|
func (b *BeaconState) currentEpochParticipationVal() []byte {
|
|
|
|
tmp := make([]byte, len(b.currentEpochParticipation))
|
|
|
|
copy(tmp, b.currentEpochParticipation)
|
2022-01-13 11:23:53 +00:00
|
|
|
return tmp
|
|
|
|
}
|
|
|
|
|
2022-01-27 08:42:32 +00:00
|
|
|
// previousEpochParticipationVal corresponding to participation bits on the beacon chain.
|
2022-01-13 11:23:53 +00:00
|
|
|
// This assumes that a lock is already held on BeaconState.
|
2022-01-27 08:42:32 +00:00
|
|
|
func (b *BeaconState) previousEpochParticipationVal() []byte {
|
|
|
|
tmp := make([]byte, len(b.previousEpochParticipation))
|
|
|
|
copy(tmp, b.previousEpochParticipation)
|
2022-01-13 11:23:53 +00:00
|
|
|
return tmp
|
|
|
|
}
|