From d0e01af4d4bba866bcdc0bb307b08f6adbd420be Mon Sep 17 00:00:00 2001 From: jeffyanta Date: Mon, 26 Jan 2026 21:16:49 -0500 Subject: [PATCH] Don't fail GetHistoricalMintData if getting the latest data point errors out --- ocp/rpc/currency/server.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ocp/rpc/currency/server.go b/ocp/rpc/currency/server.go index cdd4a33..d081a87 100644 --- a/ocp/rpc/currency/server.go +++ b/ocp/rpc/currency/server.go @@ -370,22 +370,24 @@ func (s *currencyServer) GetHistoricalMintData(ctx context.Context, req *currenc // if it's newer than the last historical point latestTime := getLatestHistoricalTime() if len(data) == 0 || data[len(data)-1].Timestamp.AsTime().Before(latestTime) { - latestReserve, err := s.data.GetCurrencyReserveAtTime(ctx, mintAccount.PublicKey().ToBase58(), latestTime) - if err != nil { - log.With(zap.Error(err)).Warn("failed to load latest currency reserve") - return nil, status.Error(codes.Internal, "") - } + func() { + latestReserve, err := s.data.GetCurrencyReserveAtTime(ctx, mintAccount.PublicKey().ToBase58(), latestTime) + if err != nil { + log.With(zap.Error(err)).Warn("failed to load latest currency reserve") + return + } - latestExchangeRate, err := s.data.GetExchangeRate(ctx, currencyCode, latestTime) - if err != nil { - log.With(zap.Error(err)).Warn("failed to load latest exchange rate") - return nil, status.Error(codes.Internal, "") - } + latestExchangeRate, err := s.data.GetExchangeRate(ctx, currencyCode, latestTime) + if err != nil { + log.With(zap.Error(err)).Warn("failed to load latest exchange rate") + return + } - data = append(data, ¤cypb.HistoricalMintData{ - Timestamp: timestamppb.New(latestTime), - MarketCap: calculateMarketCap(latestReserve.SupplyFromBonding, latestExchangeRate.Rate), - }) + data = append(data, ¤cypb.HistoricalMintData{ + Timestamp: timestamppb.New(latestTime), + MarketCap: calculateMarketCap(latestReserve.SupplyFromBonding, latestExchangeRate.Rate), + }) + }() } if len(data) == 0 {