mirror of
https://github.com/efecini/mooniversity_examples.git
synced 2025-06-06 01:12:04 +00:00
Merge pull request #5 from efecini/general-notes
Changed the main code to a function
This commit is contained in:
commit
71265d9d7a
@ -1,12 +1,15 @@
|
||||
from helpers import mainnet
|
||||
from decimal import Decimal
|
||||
|
||||
#This little program tells you the bitcoin's cycle count and the bitcoin block reward amount
|
||||
def calculate_bitcoin_cycle_and_block_reward():
|
||||
#This little program tells you the bitcoin's cycle count and the bitcoin block reward amount
|
||||
INITIAL_SUBSIDY = Decimal(50)
|
||||
BLOCKS_PER_HALVENING = 210000
|
||||
last_block = mainnet.getblockchaininfo()["blocks"]
|
||||
cycle_count = int(last_block/BLOCKS_PER_HALVENING)
|
||||
block_reward = INITIAL_SUBSIDY / cycle_count*2
|
||||
return {"Cycle":cycle_count+1, "Block_reward":block_reward}
|
||||
|
||||
initial_subsidy = Decimal(50)
|
||||
blocks_per_halvening = 210000
|
||||
last_block = mainnet.getblockchaininfo()["blocks"]
|
||||
cycle = int(last_block/blocks_per_halvening)
|
||||
initial_subsidy /= cycle*2
|
||||
|
||||
print(f"Bitcoin is in the {cycle+1}. halvening cycle and the block reward is {initial_subsidy} btc right now.")
|
||||
if __name__ == "__main__":
|
||||
cycle = calculate_bitcoin_cycle_and_block_reward()
|
||||
print(f"Bitcoin is in the {cycle.get('Cycle')}. halvening cycle and the block reward is {cycle.get('Block_reward')} ₿ right now.")
|
Loading…
x
Reference in New Issue
Block a user