func (s *Service) updateBlockSummariesForEpoch(ctx context.Context,
	md *metadata,
	epoch phase0.Epoch,
) error {
	log := log.With().Uint64("epoch", uint64(epoch)).Logger()
	if !s.blockSummaries {
		log.Trace().Msg("Block epoch summaries not enabled")
		return nil
	}
	log.Trace().Msg("Summarizing blocks for finalized epoch")
	minSlot := s.chainTime.FirstSlotOfEpoch(epoch)
	maxSlot := s.chainTime.FirstSlotOfEpoch(epoch + 1)
	for slot := minSlot; slot < maxSlot; slot++ {
		if err := s.updateBlockSummaryForSlot(ctx, slot); err != nil {
			return errors.Wrap(err, fmt.Sprintf("failed to create summary for block %d", slot))
		}
	}
	ctx, cancel, err := s.chainDB.BeginTx(ctx)
	if err != nil {
		return errors.Wrap(err, "failed to begin transaction to set summarizer metadata for block")
	}
	md.LastBlockEpoch = epoch
	if err := s.setMetadata(ctx, md); err != nil {
		cancel()
		return errors.Wrap(err, "failed to set summarizer metadata for block")
	}
	if err := s.chainDB.CommitTx(ctx); err != nil {
		cancel()
		return errors.Wrap(err, "failed to set commit transaction to set summarizer metadata for block")
	}
	return nil
}
updateBlockSummariesForEpoch updates the block summaries for a given epoch.
package standard
import (
	"context"
	"fmt"
	"github.com/attestantio/go-eth2-client/spec/phase0"
	"github.com/pkg/errors"
	"github.com/wealdtech/chaind/services/chaindb"
)