From 9c6f4326ab2faeb54db49e0f92ecb3440eab8d34 Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Thu, 12 Sep 2024 13:36:54 +0100 Subject: [PATCH] fix: check for nil values before dereferencing Signed-off-by: Elias Van Ootegem --- datanode/service/party_stats.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/datanode/service/party_stats.go b/datanode/service/party_stats.go index 733d159147..63c7a56ad8 100644 --- a/datanode/service/party_stats.go +++ b/datanode/service/party_stats.go @@ -133,7 +133,9 @@ func (s *PSvc) GetPartyStats(ctx context.Context, partyID string, markets []stri if err := addRefFeeFactors(&pfFactors, refStats[0]); err != nil { return nil, err } - data.ReferralDiscountTier = *tier.TierNumber + if tier != nil { + data.ReferralDiscountTier = *tier.TierNumber + } } // 2. volume discount stats. vdStats, _, err := s.vds.Stats(ctx, &lastE, &partyID, entities.DefaultCursorPagination(true)) @@ -148,7 +150,9 @@ func (s *PSvc) GetPartyStats(ctx context.Context, partyID string, markets []stri if err := addVolFeeFactors(&pfFactors, vdStats[0]); err != nil { return nil, err } - data.VolumeDiscountTier = *tier.TierNumber + if tier != nil { + data.VolumeDiscountTier = *tier.TierNumber + } } // 3. Volume Rebate stats. vrStats, _, err := s.vrs.Stats(ctx, &lastE, &partyID, entities.DefaultCursorPagination(true)) @@ -165,7 +169,9 @@ func (s *PSvc) GetPartyStats(ctx context.Context, partyID string, markets []stri return nil, err } pfFactors.rebate = rebate - data.VolumeRebateTier = *tier.TierNumber + if tier != nil { + data.VolumeRebateTier = *tier.TierNumber + } } for _, mkt := range mkts { // @TODO ensure non-nil slice!