Skip to content

Commit

Permalink
Code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tamirms committed Aug 30, 2021
1 parent c641009 commit 3d4ff66
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion services/horizon/internal/db2/history/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ package history
import (
"context"
"fmt"
sq "github.com/Masterminds/squirrel"
"math"

sq "github.com/Masterminds/squirrel"

"github.com/stellar/go/services/horizon/internal/db2"
"github.com/stellar/go/support/db"
"github.com/stellar/go/support/errors"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,18 @@ func (p *TradeProcessor) Commit(ctx context.Context) error {
row := trade.row
if id, ok := accountSet[trade.sellerAccount]; ok {
row.BaseAccountID = null.IntFrom(id)
} else if len(trade.sellerAccount) > 0 {
return errors.Errorf("Could not find history account id for %s", trade.sellerAccount)
}
if id, ok := accountSet[trade.buyerAccount]; ok {
row.CounterAccountID = null.IntFrom(id)
} else if len(trade.buyerAccount) > 0 {
return errors.Errorf("Could not find history account id for %s", trade.buyerAccount)
}
if id, ok := poolMap[trade.liquidityPoolID]; ok {
row.BaseLiquidityPoolID = null.IntFrom(id)
} else if len(trade.liquidityPoolID) > 0 {
return errors.Errorf("Could not find history liquidity pool id for %s", trade.liquidityPoolID)
}
row.BaseAssetID = assetMap[trade.soldAsset.String()].ID
row.CounterAssetID = assetMap[trade.boughtAsset.String()].ID
Expand Down

0 comments on commit 3d4ff66

Please sign in to comment.