|
|
@ -4,30 +4,43 @@ |
|
|
|
use warnings; |
|
|
|
use strict; |
|
|
|
|
|
|
|
# Simulate the total supply on Hush v3 mainnet |
|
|
|
|
|
|
|
my $supply = 0.0; |
|
|
|
my $block = 0; |
|
|
|
my $satoshis = 100_000_000; |
|
|
|
my $amount = int(12.5*$satoshis); |
|
|
|
my $reward0 = int(12.5*$satoshis); |
|
|
|
my $halvings = 0; |
|
|
|
my $initial = 6178674 * $satoshis; |
|
|
|
my $interval = 1_640_000; # 4 years of 75s blocks |
|
|
|
my $height = shift || -1; |
|
|
|
|
|
|
|
# Usage: ./hush_supply &> supply.csv |
|
|
|
# Usage: ./hush_supply &> supply.csv |
|
|
|
# ./hush_supply HEIGHT &> supply.csv # stop at HEIGHT |
|
|
|
|
|
|
|
# Use this to calculate when supply hits a certain value |
|
|
|
#while ($supply <= 21_000_000*$satoshis) { |
|
|
|
# Use this to calculate when block rewards end |
|
|
|
while ($halvings <= 64 && $amount >= 1) { |
|
|
|
my $reward = $reward0; |
|
|
|
# We know BR will go to zero between 7 and 8th halvings |
|
|
|
while ($halvings <= 10) { |
|
|
|
$block++; |
|
|
|
if ($block < 5) { |
|
|
|
$amount = 40_000 * $satoshis; |
|
|
|
# blocks 2-127 of Hush v3 had BR=0 |
|
|
|
if ($block == 1) { |
|
|
|
$reward = $initial; # airdropped funds from Hush v2 mainnet |
|
|
|
} elsif ($block > 1 && $block < 128) { |
|
|
|
$reward = 0; # blocks 2-127 have BR=0 |
|
|
|
} else { |
|
|
|
# Halving every 840000 blocks |
|
|
|
if ($block % 840_000 == 0) { |
|
|
|
$amount /= 2; |
|
|
|
$halvings++; |
|
|
|
if ($block < 340_000) { |
|
|
|
$reward = $reward0; |
|
|
|
} else { |
|
|
|
# Past the first halving |
|
|
|
$block -= 340_000; |
|
|
|
$halvings = 1 + ($block % $interval); |
|
|
|
$reward <<= $halvings; |
|
|
|
} |
|
|
|
$amount = int(12.5*$satoshis) / (2**$halvings); |
|
|
|
} |
|
|
|
$supply += $amount; |
|
|
|
$supply += $reward; |
|
|
|
# block, current supply, block reward amount, number of halvings |
|
|
|
printf "%s,%s,%s,%s\n", $block,$supply / $satoshis, $amount / $satoshis, $halvings; |
|
|
|
# all amounts are in satoshis |
|
|
|
printf "%s,%s,%s,%s\n",$block, $supply, $reward, $halvings; |
|
|
|
#exit(0) if ($block > 200); |
|
|
|
exit(0) if $block == $height; |
|
|
|
} |
|
|
|