Template:Mining schedule in Octave

From JaxNetwork Wiki
Jump to navigation Jump to search
clc;
clear;
close all;

N = 60; % epoch count

Premine = 36000000;

Epoch = 1:N;
FB = zeros(1,N); % first block
LB = zeros(1,N); % last block
Reward = zeros(1,N); % block reward
Supply = zeros(1,N); % supply at the end of the epoch

FB = (1:N).*6144 - 9215;
FB(1,1) = 1;

LB = (1:N).*6144 - 3072;

Reward(1,1) = 340;

if (N>0)
    b = 1;
    e = min(8,N);
    Reward(1,b:e)= 350 - (1:8).*10;
endif
if (N>8)
    b = 9;
    e = min(16,N);
    Reward(1,b:e)= 265 - (1:8).*5;
endif
if (N>16)
    b = 17;
    e = min(24,N);
    Reward(1,b:e)= 235 - (1:8).*15;
endif
if (N>24)
    b = 25;
    e = min(32,N);
    Reward(1,b:e)= 105 - (1:8).*5;
endif
if (N>32)
    b = 33;
    e = min(40,N);
    Reward(1,b:e)= 65 - (1:8).*5;
endif
if (N>40)
    b = 41;
    e = N;
    Reward(1,b:e)= 20;
endif

Supply = (LB-FB+1).*Reward;
Supply = Premine + cumsum (Supply);
str = sprintf('%.0f ',Supply);
str = fliplr(regexprep(fliplr(str), '(\d+\.)?(\d{3})(?=\S+)', '$1$2,'));
[cstr] = strsplit (str, ' ');
cstr = resize(cstr',N,1);

%[Epoch; FB ; LB; Reward; Supply]
%sprintf("|-\n |%d\n |%d\n |%d\n |%d\n |%d\n",[Epoch; FB ; LB; Reward; Supply]);

Epoch = cellstr(num2str(Epoch'));
FB = cellstr(num2str(FB'));
LB = cellstr(num2str(LB'));
Reward = cellstr(num2str(Reward'));

output = [Epoch FB LB Reward cstr]';

printf("|-\n |%s\n |%s\n |%s\n |%s\n |%s\n",output{:});