v1.0.1
This commit is contained in:
+19
-13
@@ -17,6 +17,7 @@ var mongoose = require('mongoose')
|
||||
, empoex = require('./markets/empoex')
|
||||
, ccex = require('./markets/ccex')
|
||||
, coinexchange = require('./markets/coinexchange')
|
||||
, stex = require('./markets/stex')
|
||||
, coindesk = require('./apis/coindesk');
|
||||
|
||||
function find_address(hash, cb) {
|
||||
@@ -45,7 +46,7 @@ function update_address(hash, txid, amount, type, cb) {
|
||||
if (address) {
|
||||
// if coinbase (new coins PoW), update sent only and return cb.
|
||||
if ( hash == 'coinbase' ) {
|
||||
Address.update({a_id:hash}, {
|
||||
Address.updateOne({a_id:hash}, {
|
||||
sent: address.sent + amount,
|
||||
balance: 0,
|
||||
}, function() {
|
||||
@@ -67,7 +68,7 @@ function update_address(hash, txid, amount, type, cb) {
|
||||
if ( tx_array.length > settings.txcount ) {
|
||||
tx_array.shift();
|
||||
}
|
||||
Address.update({a_id:hash}, {
|
||||
Address.updateOne({a_id:hash}, {
|
||||
txs: tx_array,
|
||||
received: received,
|
||||
sent: sent,
|
||||
@@ -79,7 +80,7 @@ function update_address(hash, txid, amount, type, cb) {
|
||||
if (type == tx_array[index].type) {
|
||||
return cb(); //duplicate
|
||||
} else {
|
||||
Address.update({a_id:hash}, {
|
||||
Address.updateOne({a_id:hash}, {
|
||||
txs: tx_array,
|
||||
received: received,
|
||||
sent: sent,
|
||||
@@ -236,6 +237,11 @@ function get_market_data(market, cb) {
|
||||
return cb(err, obj);
|
||||
});
|
||||
break;
|
||||
case 'stex':
|
||||
stex.get_data(settings.markets.coin, settings.markets.exchange, settings.markets.stex_id, function(err, obj){
|
||||
return cb(err, obj);
|
||||
});
|
||||
break;
|
||||
default:
|
||||
return cb(null);
|
||||
}
|
||||
@@ -263,7 +269,7 @@ module.exports = {
|
||||
Stats.findOne({last_usd_price: {$exists: false}}, function(err, stats) {
|
||||
if (stats) {
|
||||
// the last_usd_price needs to be added to the collection
|
||||
Stats.update({coin: coin}, {
|
||||
Stats.updateOne({coin: coin}, {
|
||||
last_usd_price: 0,
|
||||
}, function() { return cb(null); });
|
||||
}
|
||||
@@ -317,7 +323,7 @@ module.exports = {
|
||||
update_richlist: function(list, cb){
|
||||
if(list == 'received') {
|
||||
Address.find({}).sort({received: 'desc'}).limit(100).exec(function(err, addresses){
|
||||
Richlist.update({coin: settings.coin}, {
|
||||
Richlist.updateOne({coin: settings.coin}, {
|
||||
received: addresses,
|
||||
}, function() {
|
||||
return cb();
|
||||
@@ -325,7 +331,7 @@ module.exports = {
|
||||
});
|
||||
} else { //balance
|
||||
Address.find({}).sort({balance: 'desc'}).limit(100).exec(function(err, addresses){
|
||||
Richlist.update({coin: settings.coin}, {
|
||||
Richlist.updateOne({coin: settings.coin}, {
|
||||
balance: addresses,
|
||||
}, function() {
|
||||
return cb();
|
||||
@@ -563,7 +569,7 @@ module.exports = {
|
||||
});
|
||||
}, function(){
|
||||
console.log(newVotes);
|
||||
Heavy.update({coin: coin}, {
|
||||
Heavy.updateOne({coin: coin}, {
|
||||
lvote: vote,
|
||||
reward: reward,
|
||||
supply: supply,
|
||||
@@ -592,7 +598,7 @@ module.exports = {
|
||||
update_markets_db: function(market, cb) {
|
||||
get_market_data(market, function (err, obj) {
|
||||
if (err == null) {
|
||||
Markets.update({market:market}, {
|
||||
Markets.updateOne({market:market}, {
|
||||
chartdata: JSON.stringify(obj.chartdata),
|
||||
buys: obj.buys,
|
||||
sells: obj.sells,
|
||||
@@ -600,7 +606,7 @@ module.exports = {
|
||||
summary: obj.stats,
|
||||
}, function() {
|
||||
if ( market == settings.markets.default ) {
|
||||
Stats.update({coin:settings.coin}, {
|
||||
Stats.updateOne({coin:settings.coin}, {
|
||||
last_price: obj.stats.last,
|
||||
}, function(){
|
||||
return cb(null);
|
||||
@@ -623,7 +629,7 @@ module.exports = {
|
||||
// Get current stats
|
||||
Stats.findOne({coin:settings.coin}, function(err, stats) {
|
||||
// Update the last usd price
|
||||
Stats.update({coin:settings.coin}, {
|
||||
Stats.updateOne({coin:settings.coin}, {
|
||||
last_usd_price: (last_usd * stats.last_price),
|
||||
}, function(){
|
||||
return cb(null);
|
||||
@@ -644,7 +650,7 @@ module.exports = {
|
||||
}
|
||||
lib.get_supply( function (supply){
|
||||
lib.get_connectioncount(function (connections) {
|
||||
Stats.update({coin: coin}, {
|
||||
Stats.updateOne({coin: coin}, {
|
||||
coin: coin,
|
||||
count : count,
|
||||
supply: supply,
|
||||
@@ -664,7 +670,7 @@ module.exports = {
|
||||
var x = loop.iteration();
|
||||
if (x % 5000 === 0) {
|
||||
Tx.find({}).where('blockindex').lt(start + x).sort({timestamp: 'desc'}).limit(settings.index.last_txs).exec(function(err, txs){
|
||||
Stats.update({coin: coin}, {
|
||||
Stats.updateOne({coin: coin}, {
|
||||
last: start + x - 1,
|
||||
last_txs: '' //not used anymore left to clear out existing objects
|
||||
}, function() {});
|
||||
@@ -710,7 +716,7 @@ module.exports = {
|
||||
});
|
||||
}, function(){
|
||||
Tx.find({}).sort({timestamp: 'desc'}).limit(settings.index.last_txs).exec(function(err, txs){
|
||||
Stats.update({coin: coin}, {
|
||||
Stats.updateOne({coin: coin}, {
|
||||
last: end,
|
||||
last_txs: '' //not used anymore left to clear out existing objects
|
||||
}, function() {
|
||||
|
||||
Reference in New Issue
Block a user