2020-05-02 09:04:33 +02:00
|
|
|
var https = require('https');
|
|
|
|
var fs = require('fs');
|
|
|
|
|
2020-05-02 11:59:14 +02:00
|
|
|
var PATH = 'dist/mempool/resources/';
|
2020-05-02 09:04:33 +02:00
|
|
|
if (process.argv[2] && process.argv[2] === 'dev') {
|
2020-05-02 11:59:14 +02:00
|
|
|
PATH = 'src/resources/';
|
2020-05-02 09:04:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function download(filename, url) {
|
2020-05-27 20:56:32 +02:00
|
|
|
https.get(url, (response) => {
|
|
|
|
if (response.statusCode < 200 || response.statusCode > 299) {
|
|
|
|
throw new Error('HTTP Error ' + response.statusCode + ' while fetching \'' + filename + '\'');
|
|
|
|
}
|
|
|
|
response.pipe(fs.createWriteStream(filename));
|
|
|
|
})
|
|
|
|
.on('error', function(e) {
|
|
|
|
throw new Error(e);
|
2020-05-02 09:04:33 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log('Downloading assets');
|
|
|
|
download(PATH + 'assets.json', 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/index.json');
|
|
|
|
console.log('Downloading assets minimal');
|
|
|
|
download(PATH + 'assets.minimal.json', 'https://raw.githubusercontent.com/Blockstream/asset_registry_db/master/index.minimal.json');
|
2020-05-09 19:35:21 +02:00
|
|
|
console.log('Downloading mining pools info');
|
|
|
|
download(PATH + 'pools.json', 'https://raw.githubusercontent.com/btccom/Blockchain-Known-Pools/master/pools.json');
|