Files
prysm/beacon-chain/state/state-native/getters_consolidation.go
Bastin 92bd211e4d upgrade v6 to v7 (#15989)
* upgrade v6 to v7

* changelog

* update-go-ssz
2025-11-06 16:16:23 +00:00

64 lines
2.4 KiB
Go

package state_native
import (
"github.com/OffchainLabs/prysm/v7/consensus-types/primitives"
ethpb "github.com/OffchainLabs/prysm/v7/proto/prysm/v1alpha1"
"github.com/OffchainLabs/prysm/v7/runtime/version"
)
// EarliestConsolidationEpoch is a non-mutating call to the beacon state which returns the value of
// the earliest consolidation epoch field. This method requires access to the RLock on the state and
// only applies in electra or later.
func (b *BeaconState) EarliestConsolidationEpoch() (primitives.Epoch, error) {
if b.version < version.Electra {
return 0, errNotSupported("EarliestConsolidationEpoch", b.version)
}
b.lock.RLock()
defer b.lock.RUnlock()
return b.earliestConsolidationEpoch, nil
}
// ConsolidationBalanceToConsume is a non-mutating call to the beacon state which returns the value
// of the consolidation balance to consume field. This method requires access to the RLock on the
// state and only applies in electra or later.
func (b *BeaconState) ConsolidationBalanceToConsume() (primitives.Gwei, error) {
if b.version < version.Electra {
return 0, errNotSupported("ConsolidationBalanceToConsume", b.version)
}
b.lock.RLock()
defer b.lock.RUnlock()
return b.consolidationBalanceToConsume, nil
}
// PendingConsolidations is a non-mutating call to the beacon state which returns a deep copy of the
// pending consolidations slice. This method requires access to the RLock on the state and only
// applies in electra or later.
func (b *BeaconState) PendingConsolidations() ([]*ethpb.PendingConsolidation, error) {
if b.version < version.Electra {
return nil, errNotSupported("PendingConsolidations", b.version)
}
b.lock.RLock()
defer b.lock.RUnlock()
return b.pendingConsolidationsVal(), nil
}
// NumPendingConsolidations is a non-mutating call to the beacon state which returns the number of
// pending consolidations in the beacon state. This method requires access to the RLock on the state
// and only applies in electra or later.
func (b *BeaconState) NumPendingConsolidations() (uint64, error) {
if b.version < version.Electra {
return 0, errNotSupported("NumPendingConsolidations", b.version)
}
b.lock.RLock()
defer b.lock.RUnlock()
return uint64(len(b.pendingConsolidations)), nil
}
func (b *BeaconState) pendingConsolidationsVal() []*ethpb.PendingConsolidation {
if b.pendingConsolidations == nil {
return nil
}
return ethpb.CopySlice(b.pendingConsolidations)
}