@MarshallJP/

Historia-Min-Max-Calcations

Python 2.7

No description

fork
loading
Files
  • main.py

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.8158790800563247","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"IwojIGNsaWNrIFJVTiBidXR0b24gYWJvdmUKIwojIGNvbXB1dGVzIGhpc3RvcmlhIG1pbi9tYXggY29pbnMgZ2VuZXJhdGVkIG92ZXIgdGhlIG5leHQgMjUwIHllYXJzIG9yIHNvCiMKCiMgc3Vic2lkeSByZWR1Y3Rpb24gaW50ZXJ2YWwgaW4gYmxvY2tzIChzeXN0ZW0gY29uc3RhbnQpCkNZQ0xFX0xFTkdUSD0yMTAyNDAKCiMgYmxvY2tjaGFpbiBzdGF0ZSBhdCBmaXJzdCBibG9jayBvZiAyMDE5IHN1YnNpZHkgc2hpZnQKY3ljbGVfeWVhciA9IDIwMTkuMTcyNDggIyAKIyAyMDE3ICsgKCgzMSArIDI4ICsgNCArICgxNCArICgoMjEgKyAoMDQgLyA2MCkpIC8gNjApKSAvIDI0KSAvIDM2NS4yNSkKCmN5Y2xlX2hlaWdodCA9IDE1MDAwMCAKY3ljbGVfb3V0c3RhbmRpbmcgPSAyMDEyOTM0CgojIDIwMTY0MyA9PSBhdmVyYWdlIGFubnVhbCBibG9jayBkaXNjb3ZlcnkgcmF0ZSBhY3Jvc3MgNCB5ZWFycwojICAgICAgICAgYmxvY2sgaGVpZ2h0cyBhdDogeXIxICAgICAgIHlyMiAgICAgICAgICAgICAgIHlyMyAgICAgICAgICAgICAgIHlyNAojIGF2Z19ibG9ja3NfcGVyX3llYXIgPSBmbG9hdCgoMjA1NTMyICsgKDQwNTYyNi0yMDU1MzIpICsgKDYwNjM2Mi00MDU2MjYpICsgKDgwNjU3NC02MDYzNjIpKS80KQoKIyAKIyAgICAgICAgICAgICAgICAgICAgICAgICAgIGF2Zy1taW4tcGVyLXlyIGF2Zy1taW4tcGVyLWJsb2NrCmF2Z19ibG9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LCBkZWx0YV9wY3QsIG1heF9pbmZsYXRpb24sIG1pbl9pbmZsYXRpb24pCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoK"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#
# click RUN button above
#
# computes historia min/max coins generated over the next 250 years or so
#

# subsidy reduction interval in blocks (system constant)
CYCLE_LENGTH=210240

# blockchain state at first block of 2019 subsidy shift
cycle_year = 2019.17248 # 
# 2017 + ((31 + 28 + 4 + (14 + ((21 + (04 / 60)) / 60)) / 24) / 365.25)

cycle_height = 150000 
cycle_outstanding = 2012934

# 201643 == average annual block discovery rate across 4 years
#         block heights at: yr1       yr2               yr3               yr4
# avg_blocks_per_year = float((205532 + (405626-205532) + (606362-405626) + (806574-606362))/4)

# 
#                           avg-min-per-yr avg-min-per-block
avg_blocks_per_year = float((365.25*24*60)/2.627)

# FORECASTED
# 
# approx          block       minimum       maximum      min/max   difference
# date           height         coins         coins   difference   percentage
# -------    ----------    ----------    ----------   ----------   ----------
# 03/2018       840,961     7,895,396     7,979,561       84,164        1.05%
# 
# ACTUAL                                  7,961,857
# wewt!

# TODO
#cycle_year = 2018.2242 # 2018-03-22 21:25:24
# 2018 + ((31 + 28 + 22 + (21 + ((25 + (54 / 60)) / 60)) / 24) / 365.25)

# now the meat to go with those potatoes...

def block_subsidy_at(nHeight):
    nSubsidy = float(5)  # assume minimum subsidy
    for i in range(CYCLE_LENGTH, nHeight, CYCLE_LENGTH):
        nSubsidy -= nSubsidy/13
    return nSubsidy


future_year = float(cycle_year)
cycle_duration = float(CYCLE_LENGTH / avg_blocks_per_year)
totals = {
    "max" : cycle_outstanding,
    "min" : cycle_outstanding
}


print "approx         block      maximum      minimum      maximum       minimum      max/min    max/min %    max/min %"
print "date          height    generated    generated        coins         coins   difference   difference    inflation"
print "-------   ----------   ----------   ----------   ----------   -----------   ----------   ----------   ----------"
for block in range(cycle_height, cycle_height+(CYCLE_LENGTH*250), CYCLE_LENGTH):
    
    future_year += cycle_duration
    #year_part = int(divmod(future_year, 1)[1] * 12 + 1)
    month = int(divmod(future_year, 1)[1] * 12 + 1)

    cycle_subsidy = (block_subsidy_at(block) * CYCLE_LENGTH)
    max_created = float(cycle_subsidy * 1.0) # full budget allocated
    min_created = float(cycle_subsidy * 0.8) # no budget allocated
    totals["max"] += max_created
    totals["min"] += min_created 
    
    delta = totals["max"] - totals["min"]
    delta_pct = (1.0 - totals["min"]/totals["max"]) * 100
    min_inflation = (1.0/(totals["min"]/min_created)) * 100
    max_inflation = (1.0/(totals["max"]/max_created)) * 100

    #fmt="{:02d}/{}\t{}\t{:10,d}\t{:10,d}\t{:10,d}\t{:.2f}%"
    fmt="{:02d}/{}   {:10,d}   {:10,d}   {:10,d}   {:10,d}    {:10,d}   {:10,d}        {:.2f}%  {:>5.2f}/{:>4.2f}%"
    mod_scale = int(future_year) <= 2075 and 1 or 5
    if int(future_year) % mod_scale == 0:
        print fmt.format(month, int(future_year), block + CYCLE_LENGTH, int(max_created), int(min_created), int(totals["max"]), int(totals["min"]), int(delta), delta_pct, max_inflation, min_inflation)