Merge pull request #1233 from nymkappa/feature/add-mining-pool-logos

sync-assets: Download pool logos from github
This commit is contained in:
wiz 2022-02-08 05:53:31 +00:00 committed by GitHub
commit b232a9b6c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

1
frontend/.gitignore vendored
View File

@ -53,6 +53,7 @@ src/resources/assets.minimal.json
src/resources/assets-testnet.json
src/resources/assets-testnet.minimal.json
src/resources/pools.json
src/resources/mining-pools/*
# environment config
mempool-frontend-config.json

View File

@ -33,6 +33,35 @@ function download(filename, url) {
});
}
function downloadMiningPoolLogos() {
const options = {
host: 'api.github.com',
path: '/repos/mempool/mining-pools/contents/',
method: 'GET',
headers: {'user-agent': 'node.js'}
};
https.get(options, (response) => {
let chunks_of_data = [];
response.on('data', (fragments) => {
chunks_of_data.push(fragments);
});
response.on('end', () => {
let response_body = Buffer.concat(chunks_of_data);
const poolLogos = JSON.parse(response_body.toString());
for (const poolLogo of poolLogos) {
download(`${PATH}/mining-pools/${poolLogo.name}`, poolLogo.download_url);
}
});
response.on('error', (error) => {
throw new Error(error);
});
})
}
const poolsJsonUrl = 'https://raw.githubusercontent.com/btccom/Blockchain-Known-Pools/master/pools.json';
let assetsJsonUrl = 'https://raw.githubusercontent.com/mempool/asset_registry_db/master/index.json';
let assetsMinimalJsonUrl = 'https://raw.githubusercontent.com/mempool/asset_registry_db/master/index.minimal.json';
@ -55,4 +84,5 @@ console.log('Downloading testnet assets');
download(PATH + 'assets-testnet.json', testnetAssetsJsonUrl);
console.log('Downloading testnet assets minimal');
download(PATH + 'assets-testnet.minimal.json', testnetAssetsMinimalJsonUrl);
console.log('Downloading mining pool logos');
downloadMiningPoolLogos();