提起比特币和区块链,很多人都觉得如数家珍,实则知其然不知所以然。比特币是区块链的前身实现,区块链是比特币的后期提炼;如果初次接触比特币,当你想和别人交流的时候,面对的第一个概念可能就是挖矿。那么,挖矿的原理是什么?怎样利用挖矿产生比特币呢?
When you bring up the bitcoin and the block chain, many people feel like there's a number of them, but they don't know why. Bitcoin is the front of the block chain, and the block chain is the later refining of bitcoin; if you first touch bitcoin, the first concept that you might face when you want to talk to someone else is mining. So, what's the rationale for mining? How does a bitcoin come from digging?
首先,我们来思考一下为什么每个区块链系统都要发行自己的数字货币?也就是前段时间的ICO热。这里面就涉及到区块链的根本作用,这个作用就是:实现社会价值在区块链上的自由流通(类比互联网的根本作用:实现信息的自由流通)。
First of all, let's think about why each block chain system issues its own digital currency? That is, the ICO heat of the previous period. This is about the fundamental role of the block chain, which is to achieve the free flow of social values in the block chain (like the fundamental role of the Internet: the free flow of information).
比如我可以针对汽车开发一个汽车链,针对房子开发一个房子链,针对母猪开发一个母猪链等等。如果一个组织或个人的能量足够大,也可以发布一个面向全行业的链,那汽车、房子、母猪……想在各自的链上自由流转,从A的名下流转到B的名下,或者从C的名下流转到D的名下,一定需要个度量的尺度。这个尺度就是靠支出相应的数字货币来完成的。换句话说,每条链发布的数字货币,充当的是该链上价值流通的一般等价物。做个现实的类比:也就是我们生活中用于交易的人民币、美元、泰铢、英镑等中央货币,在我们购物时充当的作用。每条链可以类比成一个国家,每个国家是不是都有自己的货币系统?这样一想,大概就清楚每条链发行数字货币的目的就是促使链上的资产顺利流通了。就数字货币而言,对于想做事的人,它充当的是价值流通的一般等价物;对于敛财的人,就是个圈钱的工具。
For example, I can develop a chain of cars for cars, a chain of houses for houses, a chain of hogs for pigs, etc. If the energy of an organization or individual is large enough, I can also publish a chain for the whole industry, the cars, houses, hogs... want to move freely along their chains, move from A to B, or move from C to D. Each chain can look like a country, and each country has its own monetary system.
在区块链上,数字货币的发布模式是怎样的呢?
What are the modes of distribution of digital money on the block chain?
区块链发布链上的数字货币有两种主要形式。一种是,以国内的NEO为例,NEO的发行模式是:在系统创建的时候,一次性的在创世块里,写入1亿个NEO。借助ICO,用户可以直接用人民币认购持有。这种模式比较类似于央行发行人民币。
There are two main forms of digital money on the block chain distribution chain. One is that, in the case of national NEOs, the mode of distribution of NEOs is that, at the time the system was created, 100 million NEOs were written into the creation block. With ICO, users can subscribe to them directly in renminbi.
另一种就是类似于淘金,就是比特币这样的,通过挖矿节点,不断消耗自身的算力,来换取比特币。由于比特币系统是完全开源的,在这套开源的代码里,包含了挖矿的功能,只要一个人懂代码,就可以把这套代码进行编译部署,加入到比特币网络里面去,把挖矿功能开启,那你的宿主机开始挖矿了。
The other is gold-mining, like bitcoin, which, by digging nodes, constantly consumes its own arithmetic in exchange for bitcoin. Because the bitcoin system is fully open, in this open source code, it contains mining functions, so long as one person understands the code, it can be compiled and deployed, added to the Bitcoin network, turned on the mining function, and your host machine started digging the mine.
在比特币系统,通过自身的算法可以动态调整全网节点的挖矿难度,保证每过大约10分钟,比特币网络中,就会有一个节点挖矿成功;一旦有人挖矿成功,比特币系统就会奖励此人一定数量的比特币,这个数量也是通过算法控制的。具体说来:最开始的四年,每个挖矿成功的人会得到25个比特币的奖励,每过四年衰减一半;也就是下一个四年挖矿成功奖励12.5个,再下一个四年奖励6.25个,以此类推。大约到2140年的时候,区块链发行完毕,大约2100万个比特币,这就是比特币的总量,所以不会无限增加下去。
In the Bitcoin system, the difficulty of digging the entire net node can be dynamically adjusted through its own algorithms, ensuring that for every 10 minutes, a node in the Bitcoin network succeeds; once a person succeeds in digging, the Bitcoin system rewards a certain amount of bitcoins, which is also controlled by algorithms. Specifically, in the first four years, each successful miner will receive 25 bitcoins, which will be halved in every four years; that is, 12.5 in the next four years and 6.25 in the next four years. By the year of 2140, the block chain will be released, amounting to approximately 21 million bitcoins, which is the sum of bitcoins, so that it will not increase indefinitely.
通过上面的阐述,大家应该明白挖矿和比特币的关系了。这个关系就是:挖矿,是比特币系统发行自身数字货币,也就是比特币的必经之路。比特币系统,借助挖矿完成自身数字货币的发行。发行数字货币的过程,就是各个矿工竞争挖矿的过程。在每一个10分钟内,看谁先挖到矿,就奖励一定数量的比特币,这个奖励的过程就是比特币发行的过程;每个挖矿节点,受利益的驱使,也是不断的想办法能更快地挖矿,这也就催生了市面上的各种各样的矿池节点。
By way of illustration, one should understand the relationship between mining and bitcoin. The relationship is that mining is the way the bitcoin system issues its own digital currency, that is to say, the bitcoin. The bitcoin system, with the help of mining, produces its own digital currency. The process of issuing the digital money is that of competing miners. Within 10 minutes, every person who digs the mine first, rewards a certain amount of bitcoin. The process of issuing the bitcoin is that of the bitcoin; each dig is driven by the benefits and is constantly trying to do it faster, which leads to the creation of a variety of ponds on the market.
挖矿是比特币系统中一个形象化的表述。它背后真正的名称是POW算法,也就是工作量证明算法。工作量证明,是从经济学中来的。1993年,由两个经济学家提出来的一种策略,就是防止对服务滥用或者资源滥用,而采取的一种有效阻断的经济策略。
Mining is a visualized expression of the Bitcoin system. The real name behind it is the Pow algorithm, the workload proof algorithm.
POW算法在比特币之前就已经被广泛使用了,其中比较有名的就是Google邮箱的反垃圾邮件系统。Google是这样做的:他要求每一个给google邮件服务器发电邮的对方服务器,必须先完成一定量的计算工作,这个计算可能会耗时对方服务线程2到3秒。2到3秒的时间,如果是一个人在发邮件,是完全可以忍受的;如果对方是个发送垃圾邮件的脚本程序,他是根本无法忍受的,邮件脚本要做的是每秒成千上百封的往外发。
The Pow algorithm has been widely used before Bitcoin, and is well known as the anti-spam mail system in Google's mailbox. Google does this: he requires each other's server that e-mails to Google's mail server to complete a certain amount of computing, which may take two to three seconds for each other's service line. Two to three seconds, if a person is e-mailing, it is totally unbearable; if the other party is a script that sends spam, it is simply unbearable, and the scripts are going to be sent hundreds of times a second.
那POW算法在比特币系统是怎样应用的?中本聪在设计实现比特币系统的时候,希望每10分钟完成一次比特币发行,由于比特币网络中有成千上万个节点,那该把币发行给谁呢?按照工作量证明的策略,也就是POW算法的思路,中本聪在比特币系统中,给每一个节点出了一个难题。每个区块头的数据结构里面都有个Nonce字段,中本聪的解决的难题就是:在其他字段值不变的前提下,通过不断调节Nonce的值,来对BlockHeader这个结构体值算Hash,要求找到一个Nonce值,使得算出来的hash值小于或大于某个固定值,这个固定值,在BlockHeader结构体中,由Bits来标示。
How does the Pow algorithm work in the bitcoin system? Ben-Bone wants to do the bitcoin distribution every 10 minutes when designing the bitcoin system, and since there are tens of thousands of nodes in the Bitcoin network, who should he issue it to? According to the strategy of workload proof, which is the Pow algorithm, Ben-Bone presents a problem for each node in the Bitco-System. There is a Nonce field in the data structure of each block, and the middle-Bone-Bone solution is the problem is that the BlockHader structure is measured by constant adjustment of the Nonce value, which requires a Nonce value, which is less than or greater than a fixed value, which is specified by Bits in the BlockHader structure.
由于hash算法是一个不可以逆的算法,没法通过具体的hash值,倒推出原文。这样每个节点只能采用穷举的方法,也就是从1开始,2 3 4 5…不断的往后试。在这个过程就开始考验各个节点的CPU计算速度了,算的快的,很快就能得到Nonce值,然后他就把这个Nonce值放在结构体里,通过P2P网络广播出去。每个系统节点收到后,发现这个Nonce值是合法的,能满足要求,就认为挖矿成功。对于那些算到半截的节点,发现有人已经算出来了,就放弃本次穷举了,然后开始通过穷举的办法,去寻找下一个区块头的Nonce值。
Since the hash algorithm is a non-reversible algorithm, it is not possible to roll out the original text through a specific hash value. So that each node can only use an exhaustive method, beginning with one, two, three, four, five... a continuous back-to-back test. This process begins to test the CPU of each node to calculate speed, calculate quickly, get the Nonce value, then he puts the Nonce value in the structure, broadcast it through the P2P network. When each node is received, the Nonce value is legal and meets the requirements, and the mine is considered successful. For those nodes that are half-clanted, one finds out that the CPU has already counted, and then abandons the nonce value of the next block, and then starts to search for the Nonce value of the next block through a desperate method.
因此说,所谓挖矿,就是计算机通过穷举的办法,不断去找Nonce值、算Hash值的过程。谁先找到,谁就挖成功了。
So what's called mining is the computer's endless search for the Nonce value and the Hash value. Whoever finds it first, the dig succeeds.
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论