/** * 计算算力占比 * @param {Array} list [{user:"user1", mhs24h:100}, {user:"user2", mhs24h:320}] * @returns */ module.exports = (list) => { const total_hashrate = list.reduce((sum, user) => sum + user.mhs24h, 0); const users_weight = list.map((user) => ({ user: user.user, mhs24h: user.mhs24h, weight: user.mhs24h / total_hashrate })); return users_weight };