Skip to content

Instantly share code, notes, and snippets.

@icook
Created October 8, 2015 09:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icook/eab49fb6498cb8e48efc to your computer and use it in GitHub Desktop.
Save icook/eab49fb6498cb8e48efc to your computer and use it in GitHub Desktop.
blocks = list of all the blocks in the current chain
fork_number = the block height we'll fork to new adjustment algorithm at
coins_distributed = 0
for block in blocks:
# This block template doesn't have subsidy information, IE, we don't know
# how much was paid out in the coinbase
if block.height < fork_number:
# using the regular subsidy adjustment schedule and determine what the coinbase would have been at this height
coins_distributed += subsidy for this block
else:
# Look at the difficulty of the last 30 blocks. Determine what portion
# of the maximum subsidy would've been used for this block. Also, since
# we know how many coins have been distributed we can determine the
# maximum subsidy
coins_distributed += subsidy for this block
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment