Skip to content

Commit

Permalink
refactor: logs and var declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
hopeyen committed Dec 17, 2024
1 parent da716de commit 6dfb53b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions disperser/apiserver/server_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,18 +255,17 @@ func (s *DispersalServerV2) GetPaymentState(ctx context.Context, req *pb.GetPaym
currentReservationPeriod := meterer.GetReservationPeriod(now, reservationWindow)
binRecords, err := s.meterer.OffchainStore.GetBinRecords(ctx, req.AccountId, currentReservationPeriod)
if err != nil {
s.logger.Debug("failed to get reservation records, use placeholders", err, accountID)
s.logger.Debug("failed to get reservation records, use placeholders", "err", err, "accountID", accountID)
}
largestCumulativePayment, err := s.meterer.OffchainStore.GetLargestCumulativePayment(ctx, req.AccountId)
if err != nil {
s.logger.Debug("failed to get largest cumulative payment, use zero value", err)
s.logger.Debug("failed to get largest cumulative payment, use zero value", "err", err, "accountID", accountID)
}
// on-Chain account state
pbReservation := &pb.Reservation{}
var pbReservation *pb.Reservation
reservation, err := s.meterer.ChainPaymentState.GetReservedPaymentByAccount(ctx, accountID)
if err != nil {
s.logger.Debug("failed to get onchain reservation, use zero values", err)
pbReservation = nil
s.logger.Debug("failed to get onchain reservation, use zero values", "err", err, "accountID", accountID)
} else {
quorumNumbers := make([]uint32, len(reservation.QuorumNumbers))
for i, v := range reservation.QuorumNumbers {
Expand All @@ -289,8 +288,7 @@ func (s *DispersalServerV2) GetPaymentState(ctx context.Context, req *pb.GetPaym
var onchainCumulativePayment *big.Int
onDemandPayment, err := s.meterer.ChainPaymentState.GetOnDemandPaymentByAccount(ctx, accountID)
if err != nil {
s.logger.Debug("failed to get ondemand payment, use zero value", err)
onchainCumulativePayment = nil
s.logger.Debug("failed to get ondemand payment, use zero value", "err", err, "accountID", accountID)
} else {
onchainCumulativePayment = onDemandPayment.CumulativePayment
}
Expand Down

0 comments on commit 6dfb53b

Please sign in to comment.