func (s *Service) setMetadata(ctx context.Context, md *metadata) error {
	mdJSON, err := json.Marshal(md)
	if err != nil {
		return errors.Wrap(err, "failed to marshal metadata")
	}
	if err := s.chainDB.SetMetadata(ctx, metadataKey, mdJSON); err != nil {
		return errors.Wrap(err, "failed to update metadata")
	}
	return nil
}
setMetadata sets metadata for this service.
package standard
import (
	"context"
	"encoding/json"
	"github.com/attestantio/go-eth2-client/spec/phase0"
	"github.com/pkg/errors"
)
type metadata struct {
	LastValidatorEpoch phase0.Epoch `json:"latest_validator_epoch"`
	LastBlockEpoch     phase0.Epoch `json:"latest_block_epoch"`
	LastEpoch          phase0.Epoch `json:"latest_epoch"`
}
var metadataKey = "summarizer.standard"
func (s *Service) getMetadata(ctx context.Context) (*metadata, error) {
	md := &metadata{}
	mdJSON, err := s.chainDB.Metadata(ctx, metadataKey)
	if err != nil {
		return nil, errors.Wrap(err, "failed to fetch metadata")
	}
	if mdJSON == nil {
		return md, nil
	}
	if err := json.Unmarshal(mdJSON, md); err != nil {
		return nil, errors.Wrap(err, "failed to unmarshal metadata")
	}
	return md, nil
}