mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-23 11:57:18 +00:00
d077483577
* v3 import renamings * tidy * fmt * rev * Update beacon-chain/core/epoch/precompute/reward_penalty_test.go * Update beacon-chain/core/helpers/validators_test.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/alias.go * Update beacon-chain/db/iface/BUILD.bazel * Update beacon-chain/db/kv/kv.go * Update beacon-chain/db/kv/state.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/rpc/prysm/v1alpha1/validator/attester_test.go * Update beacon-chain/sync/initial-sync/service.go * fix deps * fix bad replacements * fix bad replacements * change back * gohashtree version * fix deps Co-authored-by: Nishant Das <nishdas93@gmail.com> Co-authored-by: Potuz <potuz@prysmaticlabs.com>
70 lines
1.7 KiB
Go
70 lines
1.7 KiB
Go
package v3
|
|
|
|
import (
|
|
"github.com/prysmaticlabs/prysm/v3/encoding/bytesutil"
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
// currentSyncCommittee of the current sync committee in beacon chain state.
|
|
// This assumes that a lock is already held on BeaconState.
|
|
func (b *BeaconState) currentSyncCommittee() *ethpb.SyncCommittee {
|
|
if !b.hasInnerState() {
|
|
return nil
|
|
}
|
|
|
|
return CopySyncCommittee(b.state.CurrentSyncCommittee)
|
|
}
|
|
|
|
// nextSyncCommittee of the next sync committee in beacon chain state.
|
|
// This assumes that a lock is already held on BeaconState.
|
|
func (b *BeaconState) nextSyncCommittee() *ethpb.SyncCommittee {
|
|
if !b.hasInnerState() {
|
|
return nil
|
|
}
|
|
|
|
return CopySyncCommittee(b.state.NextSyncCommittee)
|
|
}
|
|
|
|
// CurrentSyncCommittee of the current sync committee in beacon chain state.
|
|
func (b *BeaconState) CurrentSyncCommittee() (*ethpb.SyncCommittee, error) {
|
|
if !b.hasInnerState() {
|
|
return nil, ErrNilInnerState
|
|
}
|
|
|
|
b.lock.RLock()
|
|
defer b.lock.RUnlock()
|
|
|
|
if b.state.CurrentSyncCommittee == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return b.currentSyncCommittee(), nil
|
|
}
|
|
|
|
// NextSyncCommittee of the next sync committee in beacon chain state.
|
|
func (b *BeaconState) NextSyncCommittee() (*ethpb.SyncCommittee, error) {
|
|
if !b.hasInnerState() {
|
|
return nil, ErrNilInnerState
|
|
}
|
|
|
|
b.lock.RLock()
|
|
defer b.lock.RUnlock()
|
|
|
|
if b.state.NextSyncCommittee == nil {
|
|
return nil, nil
|
|
}
|
|
|
|
return b.nextSyncCommittee(), 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),
|
|
}
|
|
}
|