List of articles


brief introduction

We know that bitcoin is the product of mining , So in bitcoin networks , What are the characteristics of mining ? How to distribute mining income ? You can find the answer in this article .

The node structure of bitcoin

We mentioned in the last article , Bitcoin is a P2P The Internet ,P2P There are many nodes in the network , from P2P By definition , The status of each node is the same , It's not . Each node of bitcoin network has its own function .

Let's take a look at a general picture , The total number of bitcoin nodes is 4 Types :

These four types are wallets , Mining nodes , All the nodes , And network routing nodes .

Different roles combine to form a huge bitcoin network . Depending on the function , Different roles may need different types .

We introduced it above 7 A common node .

  1. Bitcoin Core This is what you download officially bitcoin Software , It contains 4 Function of type in .

  2. Full Block Chain Node, This node contains all the history information of bitcoin blockchain , It's called full node , The whole node is mainly used to verify historical transactions .

  3. Solo Miner, This is an independent mining node .

  4. SPV wallet, This is the lightweight wallet we introduced earlier .

  5. Pool Protocol Servers, This is the gateway to the bitcoin network .

Be careful , In addition to its own P2P Beyond the network protocol , One more Stratum agreement ,Stratum The protocol is applied to mining 、 And lightweight or mobile bitcoin wallets .

  1. Mining Nodes, This is the miner node connected to the bitcoin mine .

  2. SPV stratum wallet, Use Stratum Lightweight wallet for protocol .

These nodes come together , It's a huge bitcoin network .

dig

Mining is a process of increasing the bitcoin money supply . Mining also protects the security of the bitcoin system , Prevent fraudulent transactions , avoid “ Double pay ”,“ Double pay ” It means spending the same bitcoin many times . By providing computing power for the bitcoin network, the miners get the chance of bitcoin rewards .

Every time 10 In a few minutes, a new block will be “ mining ” come out , Each block contains the period from the generation of the last block to the present All the deals that happened , These transactions are added to the blockchain in turn

Miners get two types of rewards in the process of mining : New currency rewards for creating new blocks , And the transaction fee of the transactions included in the block . In order to get these rewards , Miners are scrambling to complete a hash based encryption The mathematical problem of the algorithm , The answers to these problems are included in the new block , As proof of the miner's calculated workload , go by the name of ”“ Proof of workload ”. The competition mechanism of the algorithm and the winner has the right to compete on the blockchain The mechanism of trading records , These two are the cornerstones of bitcoin security .

The process of generating new bitcoin is called mining because its reward mechanism is designed to be speed decreasing , It's like a mining process for precious metals . Bitcoin's currency is issued through mining , Similar to the central bank To issue money by printing bank notes .

The amount of bitcoin that miners get by creating a new block is about every four years ( Or, to be exact, every 210,000 Block ) Cut it in half . It starts with 2009 year 1 month Each block rewards 50 Bitcoin , And then to 2012 year 11 Half a month for each block 25 Bitcoin . After that will be in 2016 At some time in the year, we will halve the reward for each new area again 12.5 Ratio Special currency . Based on this formula , Bitcoin mining rewards decrease exponentially , until 2140 year . Then all bitcoin (20,999,999,980) It's all released .

In other words, in 2140 Years later, , There will be no more bitcoin .( A deflationary currency )

Mining nodes

In the bitcoin network , Some nodes are called professional nodes .

Same as any other complete node , These nodes receive and propagate unacknowledged transactions in the bitcoin network . However , These nodes can also integrate these transactions in new blocks .

The competition among miners is due to the spread of new areas end , It's like announcing who's the winner . For the miners , Getting a new block means that a player wins , And they lost the competition . However , The end of one round of competition also represents the end of the next round of competition Start . The new block is not just a square flag symbolizing the end of the competition ; It's also the starting gun for the next block race .

Make money deal

The first transaction in the block is a special transaction , It's called coinage or coinbase transaction .

The deal is structured by mining nodes and used to reward miners for their contributions . The mining node creates “ towards XX Pay at your address 25.09094928 Bitcoin ” Such a deal , Send the rewards that generate the transaction to your wallet . The amount of reward the miner gets for digging out the block yes coinbase Reward (25 A brand new bitcoin ) And the sum of all transaction fees in the block .

Unlike regular trading , There is no input for the coin creation transaction , Don't consume UTXO. It contains only one called coinbase The input of , Just to create a new bitcoin .

There's an output in the coin making trade , Pay to the miner's bitcoin address .

The income distribution of the mine pool

According to the income distribution of the mine pool , It can be divided into two kinds .

  1. PPLNS

Full name Pay Per Last N Shares, mean “ According to the past N Share to pay for the proceeds ”, It means , Once all the miners find a block , You will allocate the currency in the block according to the proportion of each person's own shares .

  1. PPS

PPS Ore pool ( It's similar to the working mode )PPS Its full name is Pay Per Share. In order to solve PPLNS Sometimes it's very profitable , Sometimes there's no revenue ,PPS A new algorithm is adopted .PPS According to the proportion of your calculation power in the mine pool , And it estimates the amount of minerals that can be obtained every day , Give you basic fixed income every day .

Mining direction

from 2009 Year begins , It turns out that ordinary computers can “ dig ”, But here we are 2014 year , All the mining computers have become customized for bitcoin by professional design chip companies “ mill ”.

As the computers involved in mining become more and more expensive , The cost of bitcoin production is also rising . By the end of 2014 year 10 month , The cost of producing each bitcoin has reached close to 3000 RMB . This production includes the cost of making computers , Electricity charges generated in the production process , And the cost of personnel and space . That is to say 2016 By the end of the year , Because it's produced every day 3600 Bitcoin , The amount of money invested every day is 1000 RMB 10,000 yuan . And as the competition gets more and more intense , The cost is still on the rise .

It's a waste of computing power

So what did mining do after spending so much electricity ? dedicated , It's just a hash It's just worth it .

So it's a serious waste . Of course, some people have come up with some solutions , Use the computing power to do something useful :

  • Sunny King Prime currency of
  • Primecoin (PrimeCoin Code XPM) Looking for prime numbers
  • Greider (GridCoin Code GRC) Distributed Scientific Computing

Calculation adjustment

Note that the mining difficulties of bitcoin are not necessarily increased . It's dynamically adjusted .

If in the last cycle (2016 Block ) The average block generation time is greater than 10 minute , That is, when the computing power of the whole network is declining , Then the difficulty in the current cycle will decrease , So that the block generation time is accelerated . But so far, it seems that there has not been a decline in the computing power of the whole network , The difficulty is increasing all the time .

Because it's based on post Statistics , So the change of difficulty will lag behind the change of computing power of the whole network 1~2 A cycle . If the computing power of the whole network increases , Here it is 1~2 Mining speeds up in two cycles , Mining income will increase ; conversely , Revenue reduction . But in the long run, it's balanced .

summary

This paper introduces the mining related content in bitcoin network , I hope you like it .

The author of this article :flydean Program those things

Link to this article :http://www.flydean.com/bitcoin-mine-consensus/

In this paper, the source :flydean The blog of

Welcome to my official account. : Program those things , More wonderful waiting for you !