Skip to content

Commit

Permalink
tweak comments
Browse files Browse the repository at this point in the history
  • Loading branch information
colinlyguo committed Sep 25, 2023
1 parent c83e11d commit f69abf6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions bridge-history-api/internal/controller/history_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func (c *HistoryController) GetAllClaimableTxsByAddr(ctx *gin.Context) {
types.RenderSuccess(ctx, resultData)
return
}
// Unexpected case: log and continue to fetch data from the database
// Log error for unexpected type, then fetch data from the database.
log.Error("unexpected type in cache", "expected", "*types.ResultData", "got", reflect.TypeOf(cachedData))
}

Expand Down Expand Up @@ -106,13 +106,12 @@ func (c *HistoryController) PostQueryTxsByHash(ctx *gin.Context) {
types.RenderFailure(ctx, types.ErrParameterInvalidNo, errors.New("the number of hashes in the request exceeds the allowed maximum"))
return
}

// deduplicate
hashesMap := make(map[string]struct{}, len(req.Txs))
results := make([]*types.TxHistoryInfo, 0, len(req.Txs))
uncachedHashes := make([]string, 0, len(req.Txs))
for _, hash := range req.Txs {
if _, exists := hashesMap[hash]; exists {
// Skip duplicate tx hash values.
continue
}
hashesMap[hash] = struct{}{}
Expand All @@ -138,7 +137,7 @@ func (c *HistoryController) PostQueryTxsByHash(ctx *gin.Context) {
<-releaseChan
return nil, nil
})
// add this check to fix golint: log and continue.
// Add this check to fix golint: log and continue.
if err != nil {
log.Warn("unexpected error", "err", err)
}
Expand Down

0 comments on commit f69abf6

Please sign in to comment.