From 3812e07f80cd099cd323d1562959a1d969a5fe76 Mon Sep 17 00:00:00 2001 From: husobee Date: Tue, 21 Dec 2021 10:26:59 -0500 Subject: [PATCH] bf tx consolidation tx id (#1064) * use the batch id as idempotency key bf consolidation * removing comments not needed --- promotion/drain.go | 8 +++----- utils/clients/client.go | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/promotion/drain.go b/promotion/drain.go index 8ea88f427..04867f68a 100644 --- a/promotion/drain.go +++ b/promotion/drain.go @@ -335,9 +335,8 @@ func (service *Service) SubmitBatchTransfer(ctx context.Context, batchID *uuid.U ) var ( - totalF64 float64 - depositID string - transferID string + totalF64 float64 + depositID string ) for _, v := range transfers { @@ -358,7 +357,6 @@ func (service *Service) SubmitBatchTransfer(ctx context.Context, batchID *uuid.U break } depositID = *v.DepositID - transferID = transferID + v.ID.String() } // collapse into one transaction, not multiples in a bulk upload @@ -367,7 +365,7 @@ func (service *Service) SubmitBatchTransfer(ctx context.Context, batchID *uuid.U CurrencyCode: "BAT", Amount: totalF64, DepositID: depositID, - TransferID: transferID, + TransferID: batchID.String(), SourceFrom: "userdrain", }) diff --git a/utils/clients/client.go b/utils/clients/client.go index b8b7a353c..4df1a4506 100644 --- a/utils/clients/client.go +++ b/utils/clients/client.go @@ -160,7 +160,6 @@ func (c *SimpleHTTPClient) newRequest( }) // m, _ := json.MarshalIndent(body, "", " ") - // fmt.Println(path, string(m)) if body != nil && method != "GET" { buf = new(bytes.Buffer) err := json.NewEncoder(buf).Encode(body) @@ -273,7 +272,6 @@ func (c *SimpleHTTPClient) do( _ = resp.Body.Close() // must close resp.Body = ioutil.NopCloser(bytes.NewBuffer(bodyBytes)) - // fmt.Println(req.URL.Host, req.URL.Path, string(bodyBytes)) if status >= 200 && status <= 299 { if v != nil { err = json.Unmarshal(bodyBytes, v) @@ -284,6 +282,8 @@ func (c *SimpleHTTPClient) do( return resp, nil } + logger.Warn().Int("response_status", status).Err(err).Msg("failed http client call") + logger.Debug().Str("host", req.URL.Host).Str("path", req.URL.Path).Str("body", string(bodyBytes)).Msg("failed http client call") return resp, errors.Wrap(err, ErrProtocolError) }