mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
Don't Copy The Whole Validator Map each time (#5780)
* fix copying issues * revert some changes
This commit is contained in:
parent
c1a8b41347
commit
6fed51d380
@ -945,7 +945,6 @@ func ProcessDeposit(
|
||||
pubKey := deposit.Data.PublicKey
|
||||
amount := deposit.Data.Amount
|
||||
index, ok := beaconState.ValidatorIndexByPubkey(bytesutil.ToBytes48(pubKey))
|
||||
numVals := beaconState.NumValidators()
|
||||
if !ok {
|
||||
domain, err := helpers.ComputeDomain(params.BeaconConfig().DomainDeposit, nil, nil)
|
||||
if err != nil {
|
||||
@ -976,8 +975,6 @@ func ProcessDeposit(
|
||||
if err := beaconState.AppendBalance(amount); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
numVals++
|
||||
beaconState.SetValidatorIndexByPubkey(bytesutil.ToBytes48(pubKey), uint64(numVals-1))
|
||||
} else {
|
||||
if err := helpers.IncreaseBalance(beaconState, uint64(index), amount); err != nil {
|
||||
return nil, err
|
||||
|
@ -666,10 +666,15 @@ func (b *BeaconState) AppendValidator(val *ethpb.Validator) error {
|
||||
b.lock.Lock()
|
||||
defer b.lock.Unlock()
|
||||
|
||||
// append validator to slice and add
|
||||
// it to the validator map
|
||||
b.state.Validators = append(vals, val)
|
||||
valIdx := uint64(len(b.state.Validators) - 1)
|
||||
valMap := coreutils.ValidatorIndexMap(b.state.Validators)
|
||||
|
||||
b.markFieldAsDirty(validators)
|
||||
b.AddDirtyIndices(validators, []uint64{uint64(len(b.state.Validators) - 1)})
|
||||
b.valIdxMap = coreutils.ValidatorIndexMap(b.state.Validators)
|
||||
b.AddDirtyIndices(validators, []uint64{valIdx})
|
||||
b.valIdxMap = valMap
|
||||
return nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user