Skip to content
Open

. #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 0 additions & 7 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
1.7.4
* Updated themes to Bootstrap 4.5 by using latest Bootswatch themes
* Deleted unmaintained themes that were never ported to Bootstrap4
* New setting to optionally show a logo in the navbar header: headerlogo
* New settings to switch between default, dark and light boostswatch navbars: display.navbar_dark and display.navbar_light
* Added flag icons to network view.

1.7.3
* Fixes for Historical Address Balance - seems to be fastest method that works along-side parallel indexing
* New settings to optionally show market cap in header: show_market_cap and show_market_cap_over_price
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
Iquidus Explorer - 1.7.4
Iquidus Explorer - 1.7.3
================

An open source block explorer written in node.js.

### See it in action

* [List of live explorers running Iquidus](https://github.com/iquidus/explorer/wiki/Live-Explorers)
* [Deutsche eMark](http://b.emark.tk/)
* [Vertcoin](http://explorer.vertcoin.info/)
* [TheHolyRogerCoin (ROGER) Explorer](https://explorer.theholyroger.com/)
* [CPUChain (CPU) Explorer](https://explorer.cpuchain.org/)
* [Omega Blockchain Explorer](http://explorer.omegablockchain.net/)
* [Sugarchain Explorer](https://1explorer.sugarchain.org/)
* [Florincoin](https://florincoin.info/info)
* [Maxcoin Explorer 1](https://explorer.maxcoinproject.net/)


*Note: If you would like your instance mentioned here contact me*
Expand Down
7 changes: 0 additions & 7 deletions UPGRADE
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
Note: All updates require the explorer to be restarted
1.7.3 -> 1.7.4
* Ensure that you are not using theme "Paper" or "Readable" as these were not ported by Bootswatch
* Add new settings to settings.json (see settings.json.template)
* headerlogo
* display.navbar_dark
* display.navbar_light
* Run peers script twice after initial upgrade to ensure country codes are added to mongo.

1.7.2 -> 1.7.3
* Reindex explorerdb (node --stack-size=15000 scripts/sync.js index reindex) required for Historical Address Balance
Expand Down
55 changes: 13 additions & 42 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var app = express();
// bitcoinapi
bitcoinapi.setWalletDetails(settings.wallet);
if (settings.heavy != true) {
bitcoinapi.setAccess('only', ['getinfo', 'getnetworkhashps', 'getmininginfo', 'getdifficulty', 'getconnectioncount',
bitcoinapi.setAccess('only', ['getinfo', 'getnetworkhashps', 'getmininginfo','getdifficulty', 'getconnectioncount',
'getblockcount', 'getblockhash', 'getblock', 'getrawtransaction', 'getpeerinfo', 'gettxoutsetinfo', 'verifymessage']);
} else {
// enable additional heavy api calls
Expand All @@ -34,7 +34,7 @@ if (settings.heavy != true) {
getmaxmoney - Returns the maximum possible money supply.
*/
bitcoinapi.setAccess('only', ['getinfo', 'getstakinginfo', 'getnetworkhashps', 'getdifficulty', 'getconnectioncount',
'getblockcount', 'getblockhash', 'getblock', 'getrawtransaction', 'getmaxmoney', 'getvote',
'getblockcount', 'getblockhash', 'getblock', 'getrawtransaction','getmaxmoney', 'getvote',
'getmaxvote', 'getphase', 'getreward', 'getnextrewardestimate', 'getnextrewardwhenstr',
'getnextrewardwhensec', 'getsupply', 'gettxoutsetinfo', 'verifymessage']);
}
Expand All @@ -60,45 +60,17 @@ app.use('/ext/getmoneysupply', function(req,res){

app.use('/ext/getaddress/:hash', function(req,res){
db.get_address(req.params.hash, function(address){
db.get_address_txs_ajax(req.params.hash, 0, settings.txcount, function(txs, count){
if (address) {
var last_txs = [];
for(i=0; i<txs.length; i++){
if(typeof txs[i].txid !== "undefined") {
var out = 0,
vin = 0,
tx_type = 'vout',
row = {};
txs[i].vout.forEach(function (r) {
if (r.addresses == req.params.hash) {
out += r.amount;
}
});
txs[i].vin.forEach(function (s) {
if (s.addresses == req.params.hash) {
vin += s.amount;
}
});
if (vin > out) {
tx_type = 'vin';
}
row['addresses'] = txs[i].txid;
row['type'] = tx_type;
last_txs.push(row);
}
}
var a_ext = {
address: address.a_id,
sent: (address.sent / 100000000),
received: (address.received / 100000000),
balance: (address.balance / 100000000).toString().replace(/(^-+)/mg, ''),
last_txs: last_txs,
};
res.send(a_ext);
} else {
res.send({ error: 'address not found.', hash: req.params.hash})
}
});
if (address) {
var a_ext = {
address: address.a_id,
sent: (address.sent / 100000000),
received: (address.received / 100000000),
balance: (address.balance / 100000000).toString().replace(/(^-+)/mg, ''),
};
res.send(a_ext);
} else {
res.send({ error: 'address not found.', hash: req.params.hash})
}
});
});

Expand Down Expand Up @@ -291,7 +263,6 @@ app.set('nethash', settings.nethash);
app.set('nethash_units', settings.nethash_units);
app.set('show_sent_received', settings.show_sent_received);
app.set('logo', settings.logo);
app.set('headerlogo', settings.headerlogo);
app.set('theme', settings.theme);
app.set('labels', settings.labels);

Expand Down
2 changes: 1 addition & 1 deletion bin/cluster
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var cluster = require('cluster');
var fs = require('fs');

if (cluster.isMaster) {
fs.writeFile('./tmp/cluster.pid', process.pid.toString(), function (err) {
fs.writeFile('./tmp/cluster.pid', process.pid, function (err) {
if (err) {
console.log('Error: unable to create cluster.pid');
process.exit(1);
Expand Down
2 changes: 1 addition & 1 deletion bin/instance
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ db.connect(dbString, function() {
});
}

var server = app.listen(app.get('port'), '::', function() {
var server = app.listen(app.get('port'), function() {
debug('Express server listening on port ' + server.address().port);
});
});
114 changes: 88 additions & 26 deletions lib/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,19 @@ var mongoose = require('mongoose')
, lib = require('./explorer')
, settings = require('./settings')
, fs = require('fs')
, async = require('async');
, async = require('async')
, poloniex = require('./markets/poloniex')
, bittrex = require('./markets/bittrex')
, bleutrade = require('./markets/bleutrade')
, cryptsy = require('./markets/cryptsy')
, cryptopia = require('./markets/cryptopia')
, yobit = require('./markets/yobit')
, empoex = require('./markets/empoex')
, ccex = require('./markets/ccex')
, altmarkets = require('./markets/altmarkets')
, crex = require('./markets/crex')
, tradesatoshi = require('./markets/tradesatoshi');
// , BTC38 = require('./markets/BTC38');

mongoose.set('useCreateIndex', true);
mongoose.set('useUnifiedTopology', true);
Expand Down Expand Up @@ -161,20 +173,71 @@ function save_tx(txid, blockheight, cb) {
}

function get_market_data(market, cb) {
if(fs.existsSync('./lib/markets/' + market + '.js')){
exMarket = require('./markets/' + market);
exMarket.get_data(settings.markets, function(err, obj){
return cb(err, obj);
});
}else{
return cb(null);
switch(market) {
case 'altmarkets':
altmarkets.get_data(settings.markets.coin, settings.markets.exchange, function(err, obj){
return cb(err, obj);
});
break;
case 'bittrex':
bittrex.get_data(settings.markets.coin, settings.markets.exchange, function(err, obj){
return cb(err, obj);
});
break;
case 'bleutrade':
bleutrade.get_data(settings.markets.coin, settings.markets.exchange, function(err, obj){
return cb(err, obj);
});
break;
case 'poloniex':
poloniex.get_data(settings.markets.coin, settings.markets.exchange, function(err, obj){
return cb(err, obj);
});
break;
case 'cryptsy':
cryptsy.get_data(settings.markets.coin, settings.markets.exchange, settings.markets.cryptsy_id, function(err, obj){
return cb(err, obj);
});
break;
case 'cryptopia':
cryptopia.get_data(settings.markets.coin, settings.markets.exchange, settings.markets.cryptopia_id, function (err, obj) {
return cb(err, obj);
});
break;
case 'ccex':
ccex.get_data(settings.markets.coin.toLowerCase(), settings.markets.exchange.toLowerCase(), settings.markets.ccex_key, function (err, obj) {
return cb(err, obj);
});
break;
case 'yobit':
yobit.get_data(settings.markets.coin.toLowerCase(), settings.markets.exchange.toLowerCase(), function(err, obj){
return cb(err, obj);
});
break;
case 'empoex':
empoex.get_data(settings.markets.coin, settings.markets.exchange, function(err, obj){
return cb(err, obj);
});
break;
case 'crex':
crex.get_data(settings.markets.coin, settings.markets.exchange, function (err, obj){
return cb(err, obj);
});
break;
case 'tradesatoshi':
tradesatoshi.get_data(settings.markets.coin, settings.markets.exchange, function (err, obj){
return cb(err, obj);
});
break;
default:
return cb(null);
}
}

function create_lock(lockfile, cb) {
if (settings.lock_during_index == true) {
var fname = './tmp/' + lockfile + '.pid';
fs.appendFile(fname, process.pid.toString(), function (err) {
fs.appendFile(fname, process.pid, function (err) {
if (err) {
console.log("Error: unable to create %s", fname);
process.exit(1);
Expand Down Expand Up @@ -307,15 +370,15 @@ module.exports = {
//property: 'received' or 'balance'
update_richlist: function(list, cb){
if(list == 'received') {
Address.find({}, 'a_id balance received name').sort({received: 'desc'}).limit(100).exec(function(err, addresses){
Address.find({}, 'a_id balance received').sort({received: 'desc'}).limit(100).exec(function(err, addresses){
Richlist.updateOne({coin: settings.coin}, {
received: addresses,
}, function() {
return cb();
});
});
} else { //balance
Address.find({}, 'a_id balance received name').sort({balance: 'desc'}).limit(100).exec(function(err, addresses){
Address.find({}, 'a_id balance received').sort({balance: 'desc'}).limit(100).exec(function(err, addresses){
Richlist.updateOne({coin: settings.coin}, {
balance: addresses,
}, function() {
Expand Down Expand Up @@ -372,28 +435,28 @@ module.exports = {
},

get_last_txs_ajax: function(start, length, min, cb) {
Tx.find({'total': {$gte: min}}).count(function(err, count){
Tx.find({'total': {$gte: min}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs){
if (err) {
return cb(err);
} else {
return cb(txs, count);
}
});
Tx.countDocuments({'total': {$gte: min}}, function(err, count){
Tx.find({'total': {$gte: min}}).sort({blockindex: 'desc'}).skip(Number(start)).limit(Number(length)).exec(function(err, txs){
if (err) {
return cb(err);
} else {
return cb(txs, count);
}
});
});
},

get_address_txs_ajax: function(hash, start, length, cb) {
var totalCount = 0;
AddressTx.find({a_id: hash}).count(function(err, count){
AddressTx.find({a_id: hash}).countDocuments({}, function(err, count){
if(err) {
return cb(err);
} else {
totalCount = count;
AddressTx.aggregate([
{ $match: { a_id: hash } },
{ $match: { a_id: hash } },
{ $sort: {blockindex: -1} },
{ $skip: Number(start) },
{ $skip: Number(start) },
{
$group: {
_id: '',
Expand All @@ -411,13 +474,13 @@ module.exports = {
if (err) {
return cb(err);
} else {
AddressTx.find({a_id: hash}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function (err, address_tx) {
AddressTx.find({a_id: hash}).sort({blockindex: 'desc'}).skip(Number(start)).limit(Number(length)).exec(function (err, address_tx) {
if (err) {
return cb(err);
} else {
var txs = [];
var count = address_tx.length;
var running_balance = balance_sum.length > 0 ? balance_sum[0].balance : 0;
var running_balance = balance_sum[0].balance;

var txs = [];

Expand Down Expand Up @@ -705,7 +768,7 @@ module.exports = {
count : count,
supply: supply,
connections: connections,
last: (new_stats.last ? new_stats.last : 0)});
last: new_stats.last});
});
});
});
Expand All @@ -720,7 +783,6 @@ module.exports = {
return cb();
} else {
create_lock("db_index", function (){
if (start < 1) { start = 1; }
var complete = false;
var blocks_to_scan = [];
var task_limit_blocks = settings.block_parallel_tasks;
Expand Down
Loading