2022-10-12 16:39:19 +00:00
|
|
|
package state_native
|
|
|
|
|
|
|
|
import (
|
2023-01-26 14:40:12 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/beacon-chain/state/state-native/types"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/primitives"
|
2022-10-12 16:39:19 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/runtime/version"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SetNextWithdrawalIndex sets the index that will be assigned to the next withdrawal.
|
|
|
|
func (b *BeaconState) SetNextWithdrawalIndex(i uint64) error {
|
|
|
|
if b.version < version.Capella {
|
|
|
|
return errNotSupported("SetNextWithdrawalIndex", b.version)
|
|
|
|
}
|
|
|
|
|
2022-10-22 23:10:45 +00:00
|
|
|
b.lock.Lock()
|
|
|
|
defer b.lock.Unlock()
|
2022-10-12 16:39:19 +00:00
|
|
|
|
|
|
|
b.nextWithdrawalIndex = i
|
2023-01-26 14:40:12 +00:00
|
|
|
b.markFieldAsDirty(types.NextWithdrawalIndex)
|
2022-10-12 16:39:19 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-01-25 10:09:14 +00:00
|
|
|
// SetNextWithdrawalValidatorIndex sets the index of the validator which is
|
2022-10-12 16:39:19 +00:00
|
|
|
// next in line for a partial withdrawal.
|
2023-01-26 14:40:12 +00:00
|
|
|
func (b *BeaconState) SetNextWithdrawalValidatorIndex(i primitives.ValidatorIndex) error {
|
2022-10-12 16:39:19 +00:00
|
|
|
if b.version < version.Capella {
|
2022-11-12 18:38:21 +00:00
|
|
|
return errNotSupported("SetNextWithdrawalValidatorIndex", b.version)
|
2022-10-12 16:39:19 +00:00
|
|
|
}
|
|
|
|
|
2022-10-22 23:10:45 +00:00
|
|
|
b.lock.Lock()
|
|
|
|
defer b.lock.Unlock()
|
2022-10-12 16:39:19 +00:00
|
|
|
|
2022-11-12 18:38:21 +00:00
|
|
|
b.nextWithdrawalValidatorIndex = i
|
2023-01-26 14:40:12 +00:00
|
|
|
b.markFieldAsDirty(types.NextWithdrawalValidatorIndex)
|
2022-10-12 16:39:19 +00:00
|
|
|
return nil
|
|
|
|
}
|