diff --git a/internal/db/interface.go b/internal/db/interface.go index 1ce6006..b16f598 100644 --- a/internal/db/interface.go +++ b/internal/db/interface.go @@ -106,7 +106,9 @@ type DBClient interface { ) (*DbResultMap[model.DelegationDocument], error) // SaveTermsAcceptance saves the acceptance of the terms of service of the public key SaveTermsAcceptance(ctx context.Context, termsAcceptance *model.TermsAcceptance) error + // GetLatestBtcPrice fetches the BTC price from the database. GetLatestBtcPrice(ctx context.Context) (*model.BtcPrice, error) + // SetBtcPrice sets the latest BTC price in the database. SetBtcPrice(ctx context.Context, price float64) error } diff --git a/internal/services/btc_price.go b/internal/services/btc_price.go index 2251f64..d37471a 100644 --- a/internal/services/btc_price.go +++ b/internal/services/btc_price.go @@ -38,8 +38,7 @@ func (s *Services) GetLatestBtcPriceUsd(ctx context.Context) (float64, error) { // Store in MongoDB with TTL if err := s.DbClient.SetBtcPrice(ctx, price); err != nil { - log.Ctx(ctx).Error().Err(err).Msg("failed to cache btc price") - // Don't return error here, we can still return the price + return 0, fmt.Errorf("failed to cache btc price: %w", err) } return price, nil