Remove index from txs. Explicit return and fix spent and received in addr.

This commit is contained in:
tenthirtyone 2017-08-15 10:42:36 -04:00
parent a3e4e19a9d
commit bf26304746
3 changed files with 3 additions and 5 deletions

View File

@ -47,14 +47,14 @@ module.exports = function AddressAPI(router) {
logger.log('error',
`${err}`);
}
const totalSpent = body.reduce((sum, tx) => sum + tx.outputs.reduce((sum, output) => {
const totalReceived = body.reduce((sum, tx) => sum + tx.outputs.reduce((sum, output) => {
if (output.address === req.params.addr) {
return sum + output.value;
}
return sum;
}, 0), 0);
const totalReceived = body.reduce((sum, tx) => sum + tx.inputs.reduce((sum, input) => {
const totalSpent = body.reduce((sum, tx) => sum + tx.inputs.reduce((sum, input) => {
if (input.coin && input.coin.address === req.params.addr) {
return sum + input.coin.value;
}

View File

@ -60,7 +60,6 @@ module.exports = function BlockAPI(router) {
router.get('/blocks', (req, res) => {
const limit = parseInt(req.query.limit) || MAX_BLOCKS;
getBlock(
{},
{ height: 1,
@ -75,6 +74,7 @@ module.exports = function BlockAPI(router) {
if (err) {
res.status(501).send();
logger.log('err', err);
return;
}
res.json({

View File

@ -22,8 +22,6 @@ const TransactionSchema = new Schema({
network: String,
});
TransactionSchema.index({ hash: 1 });
const Transaction = mongoose.model('Transaction', TransactionSchema);
module.exports = Transaction;