mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-07 10:12:19 +00:00
24 lines
705 B
Go
24 lines
705 B
Go
package randao
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gogo/protobuf/proto"
|
|
v "github.com/prysmaticlabs/prysm/beacon-chain/core/validators"
|
|
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
|
)
|
|
|
|
// UpdateRandaoLayers increments the randao layer of the block proposer at the given slot.
|
|
func UpdateRandaoLayers(state *pb.BeaconState, slot uint64) (*pb.BeaconState, error) {
|
|
newState := proto.Clone(state).(*pb.BeaconState)
|
|
vreg := newState.GetValidatorRegistry()
|
|
|
|
proposerIndex, err := v.BeaconProposerIndex(newState, slot)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("unable to retrieve proposer index %v", err)
|
|
}
|
|
vreg[proposerIndex].RandaoLayers++
|
|
state.ValidatorRegistry = vreg
|
|
return newState, nil
|
|
}
|