Skip to content

Commit

Permalink
Batch Save Genesis Validators (prysmaticlabs#4494)
Browse files Browse the repository at this point in the history
* save vals
* Merge branch 'master' into batchSaveGenesisValidators
  • Loading branch information
nisdas authored and cryptomental committed Feb 24, 2020
1 parent 19b0124 commit 4571b1e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions beacon-chain/blockchain/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,13 @@ func (s *Service) saveHeadNoDB(ctx context.Context, b *ethpb.SignedBeaconBlock,

// This gets called when beacon chain is first initialized to save validator indices and pubkeys in db
func (s *Service) saveGenesisValidators(ctx context.Context, state *pb.BeaconState) error {
pubkeys := make([][]byte, len(state.Validators))
indices := make([]uint64, len(state.Validators))
for i, v := range state.Validators {
if err := s.beaconDB.SaveValidatorIndex(ctx, v.PublicKey, uint64(i)); err != nil {
return errors.Wrapf(err, "could not save validator index: %d", i)
}
pubkeys[i] = v.PublicKey
indices[i] = uint64(i)
}
return nil
return s.beaconDB.SaveValidatorIndices(ctx, pubkeys, indices)
}

// This gets called when beacon chain is first initialized to save genesis data (state, block, and more) in db
Expand Down

0 comments on commit 4571b1e

Please sign in to comment.