|
|
@ -29,6 +29,7 @@ function BlockChainExplorer(opts) { |
|
|
|
} |
|
|
|
var explorer = new Explorers.Insight(url, network); |
|
|
|
explorer.getTransactions = _.bind(getTransactionsInsight, explorer, url); |
|
|
|
explorer.getActivity = _.bind(getActivityInsight, explorer, url); |
|
|
|
explorer.initSocket = _.bind(initSocketInsight, explorer, url); |
|
|
|
return explorer; |
|
|
|
default: |
|
|
@ -36,10 +37,16 @@ function BlockChainExplorer(opts) { |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
function getTransactionsInsight(url, addresses, cb) { |
|
|
|
function getTransactionsInsight(url, addresses, from, to, cb) { |
|
|
|
var qs = []; |
|
|
|
if (_.isNumber(from)) qs.push('from=' + from); |
|
|
|
if (_.isNumber(to)) qs.push('to=' + to); |
|
|
|
|
|
|
|
var url = url + '/api/addrs/txs' + (qs.length > 0 ? '?' + qs.join('&') : ''); |
|
|
|
|
|
|
|
request({ |
|
|
|
method: "POST", |
|
|
|
url: url + '/api/addrs/txs', |
|
|
|
url: url, |
|
|
|
json: { |
|
|
|
addrs: [].concat(addresses).join(',') |
|
|
|
} |
|
|
@ -49,6 +56,13 @@ function getTransactionsInsight(url, addresses, cb) { |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
function getActivityInsight(url, addresses, cb) { |
|
|
|
getTransactionsInsight(url, addresses, 0, 0, function(err, result) { |
|
|
|
if (err) return cb(err); |
|
|
|
return cb(null, result.items > 0); |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
function initSocketInsight(url) { |
|
|
|
var socket = io.connect(url, {}); |
|
|
|
return socket; |
|
|
|