import itertools # Convenient units and constants MH_s = 1e6 GH_s = 1e9 TH_s = 1e12 COIN_MONTH = (525600.0 / 12 / 10) # https://blockchain.info/charts/hash-rate on 2017/03/01 NETWORK_RATE = 3.35e6 * TH_s # http://www.coindesk.com/price/ on 2017/03/01 DOLLAR_COIN = 1225 def per_coin(hashrate): """Chance to get any given coin.""" # Assumed to be CPU previously not part of network return hashrate/(hashrate+NETWORK_RATE) def exp_dollars_month(hashrate): """Expected monthly earnings.""" return per_coin(hashrate) * COIN_MONTH * DOLLAR_COIN def exp_months_coin(hashrate): """Expected months until minting >0 coins.""" return 1.0 / (per_coin(hashrate) * COIN_MONTH) def summarize(botnet_sizes, bot_hashrates): for botnet_size, bot_hashrate in itertools.product(botnet_sizes, bot_hashrates): print '-'*20 print 'Botnet size = %.1E, bot hashrate = %.1E' % (botnet_size, bot_hashrate) hr = botnet_size * bot_hashrate print 'Total strength = %.1E' % hr edm, emc = exp_dollars_month(hr), exp_months_coin(hr) print 'Expected dollars / month = %f' % edm print 'Expected months until first coin = %f' % emc # https://en.wikipedia.org/wiki/Botnet#Historical_list_of_botnets # - 3e7 was largest in table of botnets # - Probably 1e4 or 1e5 are much more typical # https://en.bitcoin.it/wiki/Non-specialized_hardware_comparison # - CPUs were on the order of 5s or 10s of MH/s # - GPUs could get up to the 1s of GH/s, but most were on the order of 100s of MH/s summarize([1e4, 1e5, 1e6, 1e7, 1e8], [10*MH_s, 100*MH_s, 500*MH_s])
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question