Remove index from txs. Explicit return and fix spent and received in addr.
This commit is contained in:
parent
a3e4e19a9d
commit
bf26304746
@ -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;
|
||||
}
|
||||
|
||||
@ -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({
|
||||
|
||||
@ -22,8 +22,6 @@ const TransactionSchema = new Schema({
|
||||
network: String,
|
||||
});
|
||||
|
||||
TransactionSchema.index({ hash: 1 });
|
||||
|
||||
const Transaction = mongoose.model('Transaction', TransactionSchema);
|
||||
|
||||
module.exports = Transaction;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user