From c81aad0fcc2710b98ffdc1c7dd33b5d0a328ae7a Mon Sep 17 00:00:00 2001 From: hopeyen Date: Mon, 21 Oct 2024 13:22:17 -0700 Subject: [PATCH] refactor: api method name update --- disperser/apiserver/server.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/disperser/apiserver/server.go b/disperser/apiserver/server.go index 0ee24b7612..8ad2a7c9b9 100644 --- a/disperser/apiserver/server.go +++ b/disperser/apiserver/server.go @@ -304,7 +304,7 @@ func (s *DispersalServer) disperseBlob(ctx context.Context, blob *core.Blob, aut }, nil } -func (s *DispersalServer) PaidDisperseBlob(ctx context.Context, req *pb.DispersePaidBlobRequest) (*pb.DisperseBlobReply, error) { +func (s *DispersalServer) DispersePaidBlob(ctx context.Context, req *pb.DispersePaidBlobRequest) (*pb.DisperseBlobReply, error) { blob, err := s.validatePaidRequestAndGetBlob(ctx, req) quorumNumbers := req.CustomQuorumNumbers binIndex := req.BinIndex @@ -313,27 +313,26 @@ func (s *DispersalServer) PaidDisperseBlob(ctx context.Context, req *pb.Disperse if err != nil { for _, quorumID := range req.CustomQuorumNumbers { - s.metrics.HandleFailedRequest(codes.InvalidArgument.String(), fmt.Sprint(quorumID), len(req.GetData()), "PaidDisperseBlob") + s.metrics.HandleFailedRequest(codes.InvalidArgument.String(), fmt.Sprint(quorumID), len(req.GetData()), "DispersePaidBlob") } - s.metrics.HandleInvalidArgRpcRequest("PaidDisperseBlob") + s.metrics.HandleInvalidArgRpcRequest("DispersePaidBlob") return nil, api.NewInvalidArgError(err.Error()) } - reply, err := s.paidDisperseBlob(ctx, blob, quorumNumbers, binIndex, big.NewInt(int64(cumulativePayment)), signature, "", "PaidDisperseBlob") + reply, err := s.dispersePaidBlob(ctx, blob, quorumNumbers, binIndex, big.NewInt(int64(cumulativePayment)), signature, "", "DispersePaidBlob") if err != nil { - // Note the PaidDisperseBlob already updated metrics for this error. + // Note the DispersePaidBlob already updated metrics for this error. s.logger.Info("failed to disperse blob", "err", err) } else { - s.metrics.HandleSuccessfulRpcRequest("PaidDisperseBlob") + s.metrics.HandleSuccessfulRpcRequest("DispersePaidBlob") } return reply, err } -// Note: disperseBlob will internally update metrics upon an error; the caller doesn't need -// to track the error again. -func (s *DispersalServer) paidDisperseBlob(ctx context.Context, blob *core.Blob, quorumNumbers []uint32, binIndex uint32, cumulativePayment *big.Int, signature []byte, authenticatedAddress string, apiMethodName string) (*pb.DisperseBlobReply, error) { +// dispersePaidBlob checks for payment metering, otherwise does the same thing as disperseBlob +func (s *DispersalServer) dispersePaidBlob(ctx context.Context, blob *core.Blob, quorumNumbers []uint32, binIndex uint32, cumulativePayment *big.Int, signature []byte, authenticatedAddress string, apiMethodName string) (*pb.DisperseBlobReply, error) { timer := prometheus.NewTimer(prometheus.ObserverFunc(func(f float64) { - s.metrics.ObserveLatency("PaidDisperseBlob", f*1000) // make milliseconds + s.metrics.ObserveLatency("DispersePaidBlob", f*1000) // make milliseconds })) defer timer.ObserveDuration()