mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-05 17:22: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>
90 lines
1.9 KiB
Go
90 lines
1.9 KiB
Go
package state_native
|
|
|
|
import (
|
|
types "github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
)
|
|
|
|
// GenesisTime of the beacon state as a uint64.
|
|
func (b *BeaconState) GenesisTime() uint64 {
|
|
b.lock.RLock()
|
|
defer b.lock.RUnlock()
|
|
|
|
return b.genesisTime
|
|
}
|
|
|
|
// GenesisValidatorsRoot of the beacon state.
|
|
func (b *BeaconState) GenesisValidatorsRoot() []byte {
|
|
b.lock.RLock()
|
|
defer b.lock.RUnlock()
|
|
|
|
return b.genesisValidatorsRoot[:]
|
|
}
|
|
|
|
// Version of the beacon state. This method
|
|
// is strictly meant to be used without a lock
|
|
// internally.
|
|
func (b *BeaconState) Version() int {
|
|
return b.version
|
|
}
|
|
|
|
// Slot of the current beacon chain state.
|
|
func (b *BeaconState) Slot() types.Slot {
|
|
b.lock.RLock()
|
|
defer b.lock.RUnlock()
|
|
|
|
return b.slot
|
|
}
|
|
|
|
// Fork version of the beacon chain.
|
|
func (b *BeaconState) Fork() *ethpb.Fork {
|
|
if b.fork == nil {
|
|
return nil
|
|
}
|
|
|
|
b.lock.RLock()
|
|
defer b.lock.RUnlock()
|
|
|
|
return b.forkVal()
|
|
}
|
|
|
|
// forkVal version of the beacon chain.
|
|
// This assumes that a lock is already held on BeaconState.
|
|
func (b *BeaconState) forkVal() *ethpb.Fork {
|
|
if b.fork == nil {
|
|
return nil
|
|
}
|
|
|
|
prevVersion := make([]byte, len(b.fork.PreviousVersion))
|
|
copy(prevVersion, b.fork.PreviousVersion)
|
|
currVersion := make([]byte, len(b.fork.CurrentVersion))
|
|
copy(currVersion, b.fork.CurrentVersion)
|
|
return ðpb.Fork{
|
|
PreviousVersion: prevVersion,
|
|
CurrentVersion: currVersion,
|
|
Epoch: b.fork.Epoch,
|
|
}
|
|
}
|
|
|
|
// HistoricalRoots based on epochs stored in the beacon state.
|
|
func (b *BeaconState) HistoricalRoots() [][]byte {
|
|
if b.historicalRoots == nil {
|
|
return nil
|
|
}
|
|
|
|
b.lock.RLock()
|
|
defer b.lock.RUnlock()
|
|
|
|
return b.historicalRoots.Slice()
|
|
}
|
|
|
|
// balancesLength returns the length of the balances slice.
|
|
// This assumes that a lock is already held on BeaconState.
|
|
func (b *BeaconState) balancesLength() int {
|
|
if b.balances == nil {
|
|
return 0
|
|
}
|
|
|
|
return len(b.balances)
|
|
}
|