Skip to content

Commit

Permalink
fix interface
Browse files Browse the repository at this point in the history
  • Loading branch information
gusin13 committed Dec 3, 2024
1 parent bb1def5 commit b357bac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 2 additions & 0 deletions internal/db/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 1 addition & 2 deletions internal/services/btc_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b357bac

Please sign in to comment.