Skip to content

Instantly share code, notes, and snippets.

@bluepnume
Last active May 17, 2021 04:28
Show Gist options
  • Save bluepnume/cd22b4b08bc482ea4cab1f66559abff2 to your computer and use it in GitHub Desktop.
Save bluepnume/cd22b4b08bc482ea4cab1f66559abff2 to your computer and use it in GitHub Desktop.
const getBalances = async () : Promise<Counter> => {
const balances = new Counter();
for (let { miner, reward, transactions } of root.getLongestChainAsValues()) {
balances.add(miner, reward);
for (let { receiver, amount, fee, sender } of transactions) {
balances.add(miner, fee);
balances.add(receiver, amount);
balances.subtract(sender, amount);
balances.subtract(sender, fee);
}
}
return balances;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment