Skip to content

Commit

Permalink
bf tx consolidation tx id (#1064)
Browse files Browse the repository at this point in the history
* use the batch id as idempotency key bf consolidation

* removing comments not needed
  • Loading branch information
husobee committed Dec 21, 2021
1 parent 5759912 commit 3812e07
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions promotion/drain.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand All @@ -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",
})

Expand Down
4 changes: 2 additions & 2 deletions utils/clients/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down

0 comments on commit 3812e07

Please sign in to comment.