How Does Halving Work: The Code Behind the Hype
How Does Halving Work: The Code Backside the Hype
Did Satoshi Nakamoto make a mistake in the Halving lawmaking?
7052 Total views
34 Full shares
How does Bitcoin's block halving work on an engineering level? We explain with assist from Andreas Antonopoulos.
In a recent video, Antonopoulos explained the Bitcoin Cadre lawmaking that controls the halving of the Bitcoin (BTC) block reward in detail.
Bitcoin halving lawmaking. Source: Bitcoin Core Software.
Line by line explanation
Every time a Bitcoin block is evaluated or a new cake is mined, the function GetBlockSubsidy gets chosen. Its purpose is to summate the appropriate size of the block reward. Line 1240 evaluates the halving cycle and divides the current cake top past 210,000; the interval between the halving. At the time of this writing, the cake height is 629369, if we carve up it by 210,000, we become 2.99. Since the variable that stores this value is an integer type, the decimals become discarded. Using this information, the code "knows" that we take had two halvings. This is why the next halving will happen at block 630000.
Satoshi stands corrected
Lines 1242 and 1243 correct a mistake that Satoshi made in the original code. This error originally kept on halving the cake advantage by 64 halvings; the total number of halvings embedded in the Bitcoin protocol.
Line 1245 multiplies the original cake advantage of 50 by a constant COIN, which is equal to 100,000,000 Satoshis. Ironically, at that place are no Bitcoins in the Bitcoin code, merely Satoshis.
Line 1247 calculates the appropriate cake reward for the current block acme. It uses a bitwise operation which is more efficient than regular math operations. The block reward that was calculated in Line 1245 is then adjusted according to the present block reward. Currently, this would look like this:
fifty * 100,000.000 / ii2= 1,250,000,000 Satoshis or 12.5 Bitcoins.
Finally, Line 1248 returns the appropriate cake advantage when chosen past some other function or process in the Bitcoin lawmaking.
When the halving finally arrives in nigh 4 days, or 631 blocks, we tin can all take a sigh of relief and appreciate the beauty of Bitcoin's code.
Source: https://cointelegraph.com/news/how-does-halving-work-the-code-behind-the-hype
Posted by: jonesthaddle.blogspot.com

0 Response to "How Does Halving Work: The Code Behind the Hype"
Post a Comment