mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-15 14:38:20 +00:00
6406afc6cf
* Native beacon state: v3 * nogo_config * remove duplicated bazel rule * gzl * fix unnecessary assignment * review Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
54 lines
1.5 KiB
Go
54 lines
1.5 KiB
Go
package v3
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/encoding/bytesutil"
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
// currentSyncCommitteeVal of the current sync committee in beacon chain state.
|
|
// This assumes that a lock is already held on BeaconState.
|
|
func (b *BeaconState) currentSyncCommitteeVal() *ethpb.SyncCommittee {
|
|
return CopySyncCommittee(b.currentSyncCommittee)
|
|
}
|
|
|
|
// nextSyncCommitteeVal of the next sync committee in beacon chain state.
|
|
// This assumes that a lock is already held on BeaconState.
|
|
func (b *BeaconState) nextSyncCommitteeVal() *ethpb.SyncCommittee {
|
|
return CopySyncCommittee(b.nextSyncCommittee)
|
|
}
|
|
|
|
// CurrentSyncCommittee of the current sync committee in beacon chain state.
|
|
func (b *BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error) {
|
|
b.lock.RLock()
|
|
defer b.lock.RUnlock()
|
|
|
|
if b.currentSyncCommittee == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return b.currentSyncCommitteeVal(), nil
|
|
}
|
|
|
|
// NextSyncCommittee of the next sync committee in beacon chain state.
|
|
func (b *BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error) {
|
|
b.lock.RLock()
|
|
defer b.lock.RUnlock()
|
|
|
|
if b.nextSyncCommittee == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return b.nextSyncCommitteeVal(), nil
|
|
}
|
|
|
|
// CopySyncCommittee copies the provided sync committee object.
|
|
func CopySyncCommittee(data *ethpb.SyncCommittee) *ethpb.SyncCommittee {
|
|
if data == nil {
|
|
return nil
|
|
}
|
|
return ðpb.SyncCommittee{
|
|
Pubkeys: bytesutil.SafeCopy2dBytes(data.Pubkeys),
|
|
AggregatePubkey: bytesutil.SafeCopyBytes(data.AggregatePubkey),
|
|
}
|
|
}
|