You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
679 B
27 lines
679 B
const sendJson = require('./util/send-json');
|
|
const getCoinData = require('./coins');
|
|
const getAlgorithms = require('./algorithms');
|
|
|
|
const algorithms = getAlgorithms();
|
|
|
|
const getCoinAlgorithm = coin => {
|
|
return algorithms.find(algorithm => algorithm.name.toLowerCase() === coin.algorithm.toLowerCase());
|
|
};
|
|
|
|
const getData = async () => {
|
|
const coins = await getCoinData();
|
|
|
|
const data = coins
|
|
.filter(coin => getCoinAlgorithm(coin))
|
|
.map(coin => {
|
|
const algorithm = getCoinAlgorithm(coin);
|
|
coin.watts = (coin.hashrate * algorithm.joulesPerHash);
|
|
|
|
return coin;
|
|
});
|
|
|
|
return data;
|
|
};
|
|
|
|
module.exports = getData;
|
|
module.exports.handler = () => sendJson(getData);
|
|
|