Skip to content

Instantly share code, notes, and snippets.

@cyio
Last active January 6, 2018 22:57
Show Gist options
  • Save cyio/7e49ebf343e0b9f22c230d73ba90f541 to your computer and use it in GitHub Desktop.
Save cyio/7e49ebf343e0b9f22c230d73ba90f541 to your computer and use it in GitHub Desktop.
总量不是固定数值,而是由衰减规则定义 Blockchain: What is Mining? - Damien Cosset https://www.damiencosset.com/blockchain-what-is-mining/
// First 210 000 blocks reward
const start_reward = 50
// The reward is modified every 210000 blocks
const reward_interval = 210000
const max_btc = () => {
// 50 BTC = 5000000000 Satoshis
// Satoshis are the smallest denomination in bitcoin
let current_reward = 50 * 10 ** 8
let total_btc = 0
while( current_reward > 0 ){
total_btc += reward_interval * current_reward
current_reward = current_reward / 2
}
return total_btc
}
console.log(`The maximum amount of BTC created will be ${max_btc()} Satoshis, or ${max_btc() / 10**8} BTC`)
// The maximum amount of BTC created will be 2100000000000000 Satoshis, or 21000000 BTC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment