{"id":181,"date":"2021-05-20T18:05:12","date_gmt":"2021-05-20T18:05:12","guid":{"rendered":"http:\/\/www.plutohash.com\/?p=181"},"modified":"2021-05-21T11:15:19","modified_gmt":"2021-05-21T11:15:19","slug":"empty-blocks-in-the-bitcoin-blockchain","status":"publish","type":"post","link":"http:\/\/www.plutohash.com\/2021\/05\/20\/empty-blocks-in-the-bitcoin-blockchain\/","title":{"rendered":"Empty Blocks in the Bitcoin Blockchain?"},"content":{"rendered":"\n
Empty Blocks in the Bitcoin Blockchain?<\/p>\n\n\n\n
\nIn this notebook we'll have a brief look at a peculiar case: empty blocks in the Bitcoin Blockchain.\n\nPretty interesting there are \"empty\" blocks in the Bitcoin Blockchain. Well, they are not entirely empty. They just have only one transaction, which is the coinbase reward. \n\nNo other transactions. Miners earn fees from transactions, so why they should mine empty blocks? \n\nHere's a brief explanation:\nWhen a mining pool receives a new block, it needs to download the full block, validate its transactions and define a new block to mine on. To avoid wasting hashing power, they just start mining a new block with only the coinbase transaction. By mining an empty block, a miner removes the risk of duplicate transactions in their new block, which would instantly be rejected by the Bitcoin network. If the Bitcoin network rejects a block due to duplicate transactions, the miner that mined the block loses out on the coinbase reward, hence the incentive to mine empty blocks.\n\nBut let's start playing our favourite game.<\/code><\/pre>\n\n\n\nIn [1]:<\/p>\n\n\n\n
# First we import blocksci<\/em>\nimport<\/strong> blocksci\n\n# We import Counter from collections, which we will use to count items in the lists we'll create<\/em>\nfrom<\/strong> collections import<\/strong> Counter\n\n# we instantiate the chain object<\/em>\nchain =<\/strong> blocksci.<\/strong>Blockchain(\"\/BlockSci\/config_file\")\n\n# we also import <\/em>\nimport<\/strong> pandas as<\/strong> pd\nimport<\/strong> matplotlib.pyplot as<\/strong> plt\nimport<\/strong> seaborn as<\/strong> sns\n%<\/strong>matplotlib<\/strong> inline\nsns.<\/strong>set()\n\n%<\/strong>time<\/strong> \n<\/pre>\n\n\n\nCPU times: user 2 \u00b5s, sys: 2 \u00b5s, total: 4 \u00b5s\nWall time: 7.63 \u00b5s\n<\/pre>\n\n\n\nLet's start to collect all miners information from all the Blockchain. We will use the function miner() that returns the name of the Miner if he chose to write it in the Block.<\/code><\/pre>\n\n\n\nIn [2]:<\/p>\n\n\n\n
#instantiate the list of Miners of all Blocks in Bitcon Blockchain <\/em>\nlist_of_Miners =<\/strong> []\n\n#collect all Miners from Blockchain<\/em>\nfor<\/strong> x in<\/strong> chain :\n list_of_Miners.<\/strong>append(x.<\/strong>miner())\n<\/pre>\n\n\n\nLet's see what we found:<\/code><\/pre>\n\n\n\nIn [3]:<\/p>\n\n\n\n
#print list of blocks of the Blockchain<\/em>\nprint(len(list_of_Miners))\n<\/pre>\n\n\n\n684080\n<\/pre>\n\n\n\nIn [4]:<\/p>\n\n\n\n
#Enumerate Miners and Blocks mined each one<\/em>\nCounter(list_of_Miners)\n<\/pre>\n\n\n\nOut[4]:<\/p>\n\n\n\n
Counter({'Unknown': 329360,\n 'Eligius': 11425,\n 'BitMinter': 6464,\n 'BTC Guild': 32935,\n 'NMCbit': 105,\n 'Yourbtc.net': 226,\n 'simplecoin.us': 43,\n 'OzCoin': 4845,\n 'BTCServ': 9,\n 'poolserverj': 5596,\n 'SlushPool': 34600,\n 'EclipseMC': 5791,\n 'BitLC': 326,\n 'pool.mkalinin.ru': 83,\n 'MaxBTC': 449,\n 'TripleMining': 333,\n 'CoinLab': 346,\n 'HHTT': 623,\n 'stratum': 394,\n 'stratumPool': 1802,\n 'Mt Red': 77,\n '50BTC': 6392,\n 'Bitparking': 583,\n 'ASICMiner': 3127,\n 'F2Pool': 34915,\n 'ST Mining Corp': 48,\n 'GHash.IO': 789,\n '175btc': 22,\n 'Pierce and Paul': 548,\n 'MegaBigPower': 282,\n '50btc.com': 14,\n 'Polmine': 1069,\n 'AntPool': 54913,\n 'mmpool': 40,\n 'nodeStratum': 837,\n 'KnCMiner': 6290,\n 'digitalBTC': 612,\n 'bcpool.io': 8,\n 'Bitcoin Affiliate Network': 438,\n 'Solo CKPool': 245,\n 'KanoPool': 2432,\n 'BTCC Pool': 17964,\n 'TangPool': 297,\n 'BW.COM': 12414,\n 'HASHPOOL': 1,\n 'BitClub Network': 5671,\n '21 Inc.': 42,\n 'BitFury': 17268,\n '8baochi': 51,\n 'TBDice': 4,\n 'NiceHash Solo': 20,\n 'A-XBT': 7,\n 'Nexious': 1,\n 'Bravo Mining': 13,\n 'HotPool': 11,\n 'BCMonster': 15,\n 'ViaBTC': 21384,\n 'Bixin': 2374,\n 'GBMiners': 2093,\n 'BTC.com': 31616,\n 'Bitcoin.com': 2475,\n 'shawnp0wers': 4,\n 'Bitcoin India': 114,\n 'PHash.IO': 44,\n 'BTC.TOP': 16647,\n 'ConnectBTC': 153,\n 'BATPOOL': 441,\n 'xbtc.exx.com&bw.com': 116,\n 'CANOE': 321,\n 'MiningKings': 41,\n 'HAOZHUZHU': 25,\n 'BitcoinRussia': 127,\n 'Waterhole': 35,\n '7pool': 1,\n 'CKPool': 86,\n '58COIN': 745,\n 'DCExploration': 3,\n 'HashBX': 1,\n 'DPOOL': 1918,\n 'Haominer': 10,\n 'SigmaPool.com': 91})<\/pre>\n\n\n\nNow let's show the data in a chart:<\/code><\/pre>\n\n\n\nIn [5]:<\/p>\n\n\n\n
data1 =<\/strong> dict(Counter(list_of_Miners))\n\n# Data to plot<\/em>\nlabels =<\/strong> []\nsizes =<\/strong> []\n\nfor<\/strong> x, y in<\/strong> data1.<\/strong>items():\n labels.<\/strong>append(x)\n sizes.<\/strong>append(y)\n\n# Plot<\/em>\n\nplt.<\/strong>figure(figsize=<\/strong>(30,30))\nplt.<\/strong>pie(sizes, labels=<\/strong>labels)\n\nplt.<\/strong>axis('equal')\nplt.<\/strong>show()\n\n#Bars<\/em>\n\nnames =<\/strong> list(data1.<\/strong>keys())\nvalues =<\/strong> list(data1.<\/strong>values())\n\n#tick_label does the some work as plt.xticks()<\/em>\nplt.<\/strong>bar(range(len(data1)),values,tick_label=<\/strong>names)\nplt.<\/strong>savefig('bar.png')\n\n# plotting a line plot after changing it's width and height<\/em>\nplt.<\/strong>xticks(rotation=<\/strong>'vertical')\nfig =<\/strong> plt.<\/strong>gcf()\nfig.<\/strong>set_size_inches(20,10) \n\nplt.<\/strong>show()\n<\/pre>\n\n\n\n