From 5abc3637e8579970ee37d1368c362e9cdab81fcf Mon Sep 17 00:00:00 2001 From: LucaPaterlini Date: Sat, 1 Sep 2018 15:26:54 +0100 Subject: [PATCH 1/3] added gettotalreceived gettotalsent --- app.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app.js b/app.js index d55de4586..acd4a5181 100644 --- a/app.js +++ b/app.js @@ -85,6 +85,29 @@ app.use('/ext/getbalance/:hash', function(req,res){ }); }); +// light endpoint for heavy usage of received and sent coins added by LucaPaterlini (founder of Crowdcoin) support@crowdcoin.site + +app.use('/ext/gettotalreceived/:hash', function(req,res){ + db.get_address(req.param('hash'), function(address){ + if (address) { + res.send((address.received / 100000000)); + } else { + res.send({ error: 'address not found.', hash: req.param('hash')}) + } + }); +}); + + +app.use('/ext/gettotalsent/:hash', function(req,res){ + db.get_address(req.param('hash'), function(address){ + if (address) { + res.send((address.sent / 100000000)); + } else { + res.send({ error: 'address not found.', hash: req.param('hash')}) + } + }); +}); + app.use('/ext/getdistribution', function(req,res){ db.get_richlist(settings.coin, function(richlist){ db.get_stats(settings.coin, function(stats){ From 43533e4ed2d65004c68af090150f5db27b86e848 Mon Sep 17 00:00:00 2001 From: crowdcoinChain <33550798+crowdcoinChain@users.noreply.github.com> Date: Sat, 1 Sep 2018 23:05:00 +0100 Subject: [PATCH 2/3] updated info.jade permissions for the gettotalreceived and gettotalsent --- views/info.jade | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/views/info.jade b/views/info.jade index a9f9c1ba3..e184ec27c 100644 --- a/views/info.jade +++ b/views/info.jade @@ -108,6 +108,16 @@ block content * **getbalance (/ext/getbalance/hash)** *Returns current balance of given address* [#{address}/ext/getbalance/#{hashes.address}](/ext/getbalance/#{hashes.address}) + + * **gettotalreceived (/ext/gettotalreceived/hash)** + *Returns current balance of given address* + [#{address}/ext/gettotalreceived/#{hashes.address}](/ext/gettotalreceived/#{hashes.address}) + + * **gettotalsent (/ext/gettotalsent/hash)** + *Returns current balance of given address* + [#{address}/ext/gettotalsent/#{hashes.address}](/ext/gettotalsent/#{hashes.address}) + + * **getlasttxs (/ext/getlasttxs/count/min)** *Returns last [count] transactions greater than [min]* From 6ee2347e67ca98df8b97c7b0ed2a8149a426f47c Mon Sep 17 00:00:00 2001 From: crowdcoinChain <33550798+crowdcoinChain@users.noreply.github.com> Date: Sat, 1 Sep 2018 23:15:28 +0100 Subject: [PATCH 3/3] attempt to fix --- app.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app.js b/app.js index acd4a5181..14013def1 100644 --- a/app.js +++ b/app.js @@ -90,7 +90,7 @@ app.use('/ext/getbalance/:hash', function(req,res){ app.use('/ext/gettotalreceived/:hash', function(req,res){ db.get_address(req.param('hash'), function(address){ if (address) { - res.send((address.received / 100000000)); + res.send(address.received / 100000000); } else { res.send({ error: 'address not found.', hash: req.param('hash')}) } @@ -101,7 +101,7 @@ app.use('/ext/gettotalreceived/:hash', function(req,res){ app.use('/ext/gettotalsent/:hash', function(req,res){ db.get_address(req.param('hash'), function(address){ if (address) { - res.send((address.sent / 100000000)); + res.send(address.sent / 100000000); } else { res.send({ error: 'address not found.', hash: req.param('hash')}) }