mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
create the bucket only once (#8579)
Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
This commit is contained in:
parent
363771a5c7
commit
2bb0a602e4
@ -398,6 +398,15 @@ func (s *Store) saveAttestationRecords(ctx context.Context, atts []*AttestationR
|
||||
ctx, span := trace.StartSpan(ctx, "Validator.saveAttestationRecords")
|
||||
defer span.End()
|
||||
return s.update(func(tx *bolt.Tx) error {
|
||||
// Initialize buckets for the lowest target and source epochs.
|
||||
lowestSourceBucket, err := tx.CreateBucketIfNotExists(lowestSignedSourceBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lowestTargetBucket, err := tx.CreateBucketIfNotExists(lowestSignedTargetBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bucket := tx.Bucket(pubKeysBucket)
|
||||
for _, att := range atts {
|
||||
pkBucket, err := bucket.CreateBucketIfNotExists(att.PubKey[:])
|
||||
@ -448,16 +457,6 @@ func (s *Store) saveAttestationRecords(ctx context.Context, atts []*AttestationR
|
||||
return errors.Wrapf(err, "could not save target epoch %d for epoch %d", att.Target, att.Source)
|
||||
}
|
||||
|
||||
// Initialize buckets for the lowest target and source epochs.
|
||||
lowestSourceBucket, err := tx.CreateBucketIfNotExists(lowestSignedSourceBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
lowestTargetBucket, err := tx.CreateBucketIfNotExists(lowestSignedTargetBucket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If the incoming source epoch is lower than the lowest signed source epoch, override.
|
||||
lowestSignedSourceBytes := lowestSourceBucket.Get(att.PubKey[:])
|
||||
var lowestSignedSourceEpoch types.Epoch
|
||||
|
Loading…
Reference in New Issue
Block a user