Skip to content

Commit

Permalink
review followup
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Dec 3, 2021
1 parent f53f133 commit ae1af1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
18 changes: 9 additions & 9 deletions server/market/orderrouter.go
Expand Up @@ -260,7 +260,7 @@ func (r *OrderRouter) handleLimit(user account.AccountID, msg *msgjson.Message)
}

lotSize := tunnel.LotSize()
rpcErr = r.checkPrefixTrade(assets, lotSize, &limit.Prefix, &limit.Trade, limit.Rate, true)
rpcErr = r.checkPrefixTrade(assets, lotSize, &limit.Prefix, &limit.Trade, true)
if rpcErr != nil {
return rpcErr
}
Expand Down Expand Up @@ -349,7 +349,7 @@ func (r *OrderRouter) handleMarket(user account.AccountID, msg *msgjson.Message)
// Passing sell as the checkLot parameter causes the lot size check to be
// ignored for market buy orders.
lotSize := tunnel.LotSize()
rpcErr = r.checkPrefixTrade(assets, lotSize, &market.Prefix, &market.Trade, 0, sell)
rpcErr = r.checkPrefixTrade(assets, lotSize, &market.Prefix, &market.Trade, sell)
if rpcErr != nil {
return rpcErr
}
Expand Down Expand Up @@ -554,13 +554,13 @@ func (r *OrderRouter) processTrade(oRecord *orderRecord, tunnel MarketTunnel, as
if sell {
reqVal = calc.RequiredOrderFunds(trade.Quantity, uint64(spendSize), lots, &fundingAsset.Asset)
} else {
// This is a market buy order, so the quantity gets special handling.
// 1. The quantity is in units of the quote asset.
// 2. The quantity has to satisfy the market buy buffer.
if rate > 0 {
if rate > 0 { // limit buy
quoteQty := calc.BaseToQuote(rate, trade.Quantity)
reqVal = calc.RequiredOrderFunds(quoteQty, uint64(spendSize), lots, &assets.quote.Asset)
} else {
// This is a market buy order, so the quantity gets special handling.
// 1. The quantity is in units of the quote asset.
// 2. The quantity has to satisfy the market buy buffer.
midGap := tunnel.MidGap()
if midGap == 0 {
midGap = tunnel.RateStep()
Expand All @@ -584,7 +584,7 @@ func (r *OrderRouter) processTrade(oRecord *orderRecord, tunnel MarketTunnel, as
return false, nil
}

log.Tracef("Searching for %s coins %v for new limit order", fundingAsset.Symbol, coinStrs)
log.Tracef("Searching for %s coins %v for new order", fundingAsset.Symbol, coinStrs)
r.latencyQ.Wait(&wait.Waiter{
Expiration: time.Now().Add(fundingTxWait),
TryFunc: func() bool {
Expand All @@ -598,7 +598,7 @@ func (r *OrderRouter) processTrade(oRecord *orderRecord, tunnel MarketTunnel, as
}

// Send the order to the epoch queue where it will be time stamped.
log.Tracef("Found and validated %s coins %v for new limit order", fundingAsset.Symbol, coinStrs)
log.Tracef("Found and validated %s coins %v for new order", fundingAsset.Symbol, coinStrs)
if msgErr := r.submitOrderToMarket(tunnel, oRecord); msgErr != nil {
r.respondError(oRecord.msgID, user, msgErr)
}
Expand Down Expand Up @@ -895,7 +895,7 @@ func checkTimes(prefix *msgjson.Prefix) *msgjson.Error {
// checkPrefixTrade validates the information in the prefix and trade portions
// of an order.
func (r *OrderRouter) checkPrefixTrade(assets *assetSet, lotSize uint64, prefix *msgjson.Prefix,
trade *msgjson.Trade, rate uint64, checkLot bool) *msgjson.Error {
trade *msgjson.Trade, checkLot bool) *msgjson.Error {
// Check that the client's timestamp is still valid.
rpcErr := checkTimes(prefix)
if rpcErr != nil {
Expand Down
2 changes: 0 additions & 2 deletions server/swap/swap.go
Expand Up @@ -1464,8 +1464,6 @@ func (s *Swapper) processInit(msg *msgjson.Message, params *msgjson.Init, stepIn
stepInfo.match.Status = stepInfo.nextStep
stepInfo.match.mtx.Unlock()

fmt.Println("-setting new status", stepInfo.nextStep)

// Only unlock match map after the statuses and txn times are stored,
// ensuring that checkInaction will not revoke the match as we respond and
// request counterparty audit.
Expand Down

0 comments on commit ae1af1a

Please sign in to comment.