Skip to content

Commit

Permalink
[FIX] code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sentientwaffle committed May 10, 2016
1 parent 3b4fc0b commit d84184e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/controllers/routes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict'

const co = require('co')
const log = require('../common').log('routes')
const requestUtil = require('five-bells-shared/utils/request')
const routingTables = require('../services/routing-tables')
const routeBroadcaster = require('../services/route-broadcaster')
Expand All @@ -15,8 +17,11 @@ exports.post = function * () {

const connector = routes[0] && routes[0].connector
if (connector && !knownConnectors[connector]) {
yield routeBroadcaster.broadcast()
knownConnectors[connector] = true
co(routeBroadcaster.broadcast.bind(routeBroadcaster))
.catch(function (err) {
log.warn('error broadcasting routes: ' + err.message)
})
}

this.status = 200
Expand Down
7 changes: 5 additions & 2 deletions src/lib/route-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ class RouteBuilder {
const _nextHop = this._findNextHop(query)
if (!_nextHop) throwAssetsNotTradedError()
if (query.sourceAmount) {
_nextHop.finalAmount = (+_nextHop.finalAmount * (1 - this.slippage)).toFixed(15)
_nextHop.finalAmount = (new BigNumber(_nextHop.finalAmount)).times(1 - this.slippage).toString()
} else { // fixed destinationAmount
_nextHop.sourceAmount = (+_nextHop.sourceAmount * (1 + this.slippage)).toFixed(15)
_nextHop.sourceAmount = (new BigNumber(_nextHop.sourceAmount)).times(1 + this.slippage).toString()
}
const nextHop = yield this._roundHop(_nextHop)

Expand All @@ -62,6 +62,9 @@ class RouteBuilder {
}

/**
* Given a source transfer with an embedded final transfer, get the next
* transfer in the chain.
*
* @param {Transfer} sourceTransfer
* @returns {Transfer} destinationTransfer
*/
Expand Down

0 comments on commit d84184e

Please sign in to comment.