mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-11 20:20:05 +00:00
963acefe12
Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: terence tsao <terence@prysmaticlabs.com> Co-authored-by: Kasey Kirkham <kasey@users.noreply.github.com> Co-authored-by: Preston Van Loon <preston@prysmaticlabs.com> Co-authored-by: kasey <489222+kasey@users.noreply.github.com> Co-authored-by: Dan Loewenherz <dloewenherz.adm@gmail.com> Co-authored-by: prestonvanloon <preston@prysmaticlabs.com> Co-authored-by: Fredrik Svantes <fredrik@ethereum.org> Co-authored-by: Leo Lara <leolara@users.noreply.github.com>
54 lines
1.4 KiB
Go
54 lines
1.4 KiB
Go
package v3
|
|
|
|
// CurrentEpochParticipation corresponding to participation bits on the beacon chain.
|
|
func (b *BeaconState) CurrentEpochParticipation() ([]byte, error) {
|
|
if !b.hasInnerState() {
|
|
return nil, nil
|
|
}
|
|
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() {
|
|
return nil, nil
|
|
}
|
|
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
|
|
}
|