Skip to content

Commit

Permalink
larger bulk insert
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmcgary committed Dec 7, 2024
1 parent 6fe6952 commit 7df463e
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions pkg/indexer/restakedStrategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func (idx *Indexer) getAndInsertRestakedStrategies(
zap.Int("count", len(results)),
zap.Uint64("blockNumber", blockNumber),
)
strategiesToInsert := make([]*storage.OperatorRestakedStrategies, 0)
for _, result := range results {
avs := result.Avs
operator := result.Operator

strategiesToInsert := make([]*storage.OperatorRestakedStrategies, 0)
for _, restakedStrategy := range result.Results {
strategiesToInsert = append(strategiesToInsert, &storage.OperatorRestakedStrategies{
AvsDirectoryAddress: strings.ToLower(avsDirectoryAddress),
Expand All @@ -104,20 +104,20 @@ func (idx *Indexer) getAndInsertRestakedStrategies(
Strategy: restakedStrategy.String(),
})
}
inserted, err := idx.MetadataStore.BulkInsertOperatorRestakedStrategies(strategiesToInsert)
if err != nil {
idx.Logger.Sugar().Errorw("Failed to save restaked strategies",
zap.Error(err),
zap.String("avsDirectoryAddress", avsDirectoryAddress),
zap.Uint64("blockNumber", blockNumber),
)
return err
}
idx.Logger.Sugar().Infow("Inserted restaked strategies",
zap.Int("insertedCount", len(inserted)),
zap.Int("inputCount", len(strategiesToInsert)),
}
inserted, err := idx.MetadataStore.BulkInsertOperatorRestakedStrategies(strategiesToInsert)
if err != nil {
idx.Logger.Sugar().Errorw("Failed to save restaked strategies",
zap.Error(err),
zap.String("avsDirectoryAddress", avsDirectoryAddress),
zap.Uint64("blockNumber", blockNumber),
)
return err
}
idx.Logger.Sugar().Infow("Inserted restaked strategies",
zap.Int("insertedCount", len(inserted)),
zap.Int("inputCount", len(strategiesToInsert)),
)
return nil
}

Expand Down

0 comments on commit 7df463e

Please sign in to comment.