【区块链~学习】从0到1认识比特币--挖矿

访客 阅读:17 2024-07-10 15:31:58 评论:0
美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

【本文由赞我(zaneds.com)独家冠名】

i'm complimenting me with the exclusive name of zaneds.com.

文/鹤兰

I don't know what you're talking about.

上篇我们谈过比特币的诞生背景,知道了币为何而来,那它底层的区块链技术又是如何将一个个区块创造出来并形成链的?所谓的挖矿又是怎么一回事呢?让我们带着问题来一场追根溯源。

We talked about the birth of Bitcoin, and we know why the coin came, and how the bottom of its block chain technology created and chained a block? What about the so-called mining? Let's go back and forth with the problem.

1、为什么要挖矿?

比特币的诞生使交易信息可以被全网记录验证成为可能,无论是小到你跟你好朋友借了5元钱,还是大到商业贸易中动辄几十万的交易,都可以被记录在链。你可能会有疑惑,这些交易信息谁负责记录下来的呢?别人又为什么肯心甘情愿去做记账人呢?记下的帐如果不对怎么办?

The birth of Bitcoin made it possible for transactional information to be validated by a full web record, whether it was small enough for you to borrow five dollars from your best friend or for a multi-million-dollar trade to be recorded in the chain. You might have doubts. Who's in charge of recording these transactions? Why would anyone else want to be a bookkeeper?

这就是挖矿的原因。所谓挖矿,其实就是将一段时间内网上所有交易信息进行打包,然后把这些交易信息存在区块中,当然,这些负责记录的人不会白白记录,会得到一些奖励----比特币和实际交易过程中的手续费,这也是挖矿的意义。

This is why the mines are mined. This is what is known as mining, which is to pack up all the information on the Internet over a period of time, and then put it in blocks. Of course, these record keepers will not record it in vain, and they will receive some rewards - bitcoin and fees in the actual course of the transaction, which is what mining is all about.

可以说,有交易产生,就需要人来记录交易,要想有人来记录交易,就要给这批人一些奖励,俗话说,有钱能使鬼推磨,也是这个道理。

It can be said that when a transaction arises, people need to record the transaction, and if someone wants to record the transaction, they need to be rewarded.

2、如何挖矿?

1)挖矿过程

我们先用一个简单的记账场景来理解下挖矿的过程:

Let's use a simple accounting scene to understand the mining process:

假如从现在开始,10分钟过去了,在这段时间内网络上出现了很多交易信息,想要记账的很多人都虎视眈眈盯着这笔交易出来,因为记下这笔账就能得到比特币的奖励。但每个人记账前还需要算一道数学题,谁先解出答案才能获得记账权。于是,第一个最快解出答案的人,向其他人大喊一声:“我已经解出答案了!”然后把记账的结果发给其他人,其他还在计算的人便停下来,开始验证记的结果,验证通过,记账的人就会得到钱的奖励。

If, from now on, 10 minutes have passed, a lot of information has appeared on the Internet during this period, and many people who want to keep their books stare at the deal, because recording them will be rewarded by bitcoin. But there is a math question that everyone has to count before doing them, and who gets the answers first. So, the first person who solves the answers most quickly, shouts to others: “I have solved the answer!” and then sends the results to others, and others who are still counting, stop and start to verify the results, and by doing so, the bookkeeper gets the money.

而真正的挖矿原理会更复杂些:

and the true mining doctrine will be more complicated:

由上篇文章我们知道比特币底层技术是区块链,区块链又是由区块组成,而每个区块中又由区块头+区块体构成。

From the previous article, we knew that the bottom technology of Bitcoin was a block chain, which in turn consisted of blocks, each of which consisted of blocks + blocks.

区块头中通常包含前一个区块的哈希散列值、Merkle根、时间戳、难度目标、以及一个填充的随机值。区块体中常有近400多个交易信息。

Block headers typically contain Hashi hash values from the previous block, Merkle root, time stampes, difficulty targets, and a filled random value. There are often more than 400 transactional information in the block.

比特币挖矿的过程就是一个包含着交易信息的区块产生的过程,一个区块的产生包含着它区块头中哈希值被解出的随机值的过程。

The process by which Bitcoin digs is a process by which a block containing transactional information is generated, a process by which a random value of the Hashi value is removed from the head of a block.

具体的过程是这样的:

The process is as follows:

每隔10分钟,网上一些交易信息产生,矿工们先将交易信息打包成一个区块,然后开始算它的哈希值。算出来的话,通过全网传播给别的矿工,别的矿工停止计算,开始验证,验证正确的话,选择接受这个区块,记录到自己的账本中,然后进行下一个区块的竞争猜谜,而这个包含着新交易信息的新区块,挂到上个区块后面。同时,矿工获得一定的比特币奖励,后期还会有交易费。

Every 10 minutes, some transactional information is generated online, and the miners pack the transaction information into a block, and then start to calculate its Hashi value. When it is calculated, the miners pass it through the net to other miners, stop counting, start verifying, verify correctness, choose to accept the block, record it in their own account book, then engage in a competition puzzle for the next block, which contains new trading information, and hang it behind the previous block. At the same time, the miners receive a bit of bitcoin reward, and there will be transaction costs later.

如果验证未通过,或者矿工有作弊行为,都会导致网络的节点验证不通过,直接丢弃其打包的区块,作弊的节点耗费的成本就白费了,因此巨大的挖矿成本,也使得矿工自觉遵守共识协议,从而保证安全。

Failure to do so, or fraudulent behaviour on the part of miners, can lead to the failure of network nodes, the direct abandonment of their packed blocks, and the cost of cheating nodes are in vain, so that the huge mining costs also allow miners to feel that they are complying with the consensus agreement and thereby ensure safety.

2)挖矿工具

传统挖矿中,煤矿工人需要挥动铁锹、戴着探照灯进行,而比特币挖矿中,这种工具叫挖矿机,其实就是计算的电脑。这类电脑一般有专业的挖矿芯片,多采用烧显卡的方式工作,耗电量较大。

In traditional mining, coal miners need to wave shovels and wear searchlights, whereas in bitcoin mining, this tool is called a mine-digger, which is actually a computing computer. These computers typically have specialized mining chips, work more often in the form of a burning card, and consume more electricity.

一开始,参与挖矿的人少,需要算力小,很多人用一台普通电脑就可以计算出哈希值解的结果。

At the outset, fewer people were involved in mining and needed less money, and many could calculate the results of Hashi's decomposition using a common computer .

后来随着比特币价格暴涨,矿工人数增加,挖矿过程中需要的算力增大,挖矿难度上升,开始出现专业矿机,当把很多矿机集合在一起,就成了专门挖矿的矿场

As the price of Bitcoin soared, the number of miners increased, the computing power needed in the mining process increased, the difficulty of mining increased, the professional miner began to appear , and when a large number of miners were brought together, it became the mine dedicated to mining >.

矿池的概念是,建一个平台,所有有计算能力的人都可以参与进来,当得到奖励,按每个人的计算力高低分配奖金。

And the concept of ponds is to create a platform in which all those who are able to calculate can participate and, when rewarded, to distribute bonuses according to each individual's computing power.

3、挖矿相关概念

a:工作量证明

a: Workload certification

工作量证明(Proof Of Work,简称POW),简单理解就是一份证明,用来确认你做过一定量的工作。在做一份工作中,记录整个过程的工作量效率很低,而通过对工作结果考量证明你的工作量,就会更高效。如现在招聘方通过你的学历证书作为你能力的考量等。

The simple understanding of workload certification (Proof Of Work, POW) is a confirmation that you have done a certain amount of work. In doing one job, recording the entire process is inefficient, and proving your workload by taking into account the results of the work will be more efficient.

在比特币挖矿中,工作量的证明常指算力。什么是算力?就是我们上面提到的解出哈希随机值的计算能力,算的越快,最先解出答案,我们就称之为算力越大,算力越大,才能在挖矿中更大概率获得奖励。例如求2的n次方等于多少,越快得出结果的算力就越强。

"b" in bitcoin mining, the proof of workload is often arithmetic . What is arithmetic? The faster the calculation of Hashi random values, as we have mentioned above, the sooner the answer comes out, we call it the greater the calculation, the greater the calculation, the greater the probability of the mine being rewarded. For example, the faster the calculation of the outcome is achieved, the better.

b:哈希函数(Hash Function)

b: Hash Action

在挖矿过程中,我们说矿工需要解一些题才能通关,这个计算题指的就是哈希函数。

During the mining process, we said that miners needed to solve some of the problems in order to get through, and that was the Hashi function.

哈希函数,也称为散列函数,给定一个输入x,它会算出相应的输出H(x)。

The Hashi function, also known as the hash function, gives an input x which calculates the corresponding output H(x).

对于比特币这种加密系统所使用的哈希函数,它有如下特点:把变长转换为定长;计算容易倒推难;哈希值对细节敏感(输入值稍微改变输出值大不一样)。

For the Hashi function used for this encryption system, Bitcoin, it has the following characteristics: converts the length to a fixed length; calculation is difficult to calculate; the Hashi value is sensitive to the details (the input value slightly changes the output value).

scalers老师用了一个很通俗易懂的类比:哈希函数就像一个有特异功能的榨汁机,无论你丢进去多少种水果,榨出来的果汁总是一杯;一旦换了一种水果,榨出来的果汁口感和颜色完全不一样。

Teacher scalers used a very general analogy: the Hashi function is like a juicer with a special function, no matter how many kinds of fruit you throw in, the extracted juice is always a glass; once a fruit has been replaced, the extracted juice feels completely different from the colour.

这些特点使得区块链中的交易信息不易篡改、具有匿名性成为可能。

These characteristics make it possible for transactional information in the block chain to be not easily tampered with and anonymous.

c:通货紧缩的比特币

c: deflationary bitcoin

比特币之所以被人们成为通货紧缩币,是因为它总量只有2100万枚,大概到2140年后区块不再产生新币;每四年产量减少一半。

Bitcoin has been turned into a deflationary currency because it has a total of only 21 million pieces and will no longer produce a new currency in blocks after 2140; production is reduced by half every four years.

从第一块比特币问世后的初始四年,矿工创建一个区块奖励其50枚,另外还有交易费。比特币每四年减半后,到现在矿工一次奖励减少到12.5枚。当全部的比特币被发行出来后,矿工矿工就只剩交易费作为奖励了。

In the first four years of the first bitcoin, miners created a block to reward 50 of them, plus transaction fees. After halving the bitcoin every four years, it has now been reduced to 12.5 at a time. When all bitcoins are released, the miners will only be rewarded with transaction fees.

因为总量有限,也是其价格奇高的原因之一,因此被称为通货紧缩的数字货币。

Because of their limited aggregates, they are also one of the reasons for their exceptionally high prices and are therefore referred to as deflationary digital currencies.

d:UTXO

有人说现实世界中没有比特币,只有UTXO。

Some say there's no bitcoin in the real world, only UTXO.

什么是UTXO呢?官方释义为:未花费的交易输出,它是比特币交易的最基本单元。比特币的交易由交易输入和交易输出组成,每一笔交易都要花费一笔输入,产生一笔输出,而其所产生的输出,就是"未花费过的交易输出",也就是 UTXO。

What is UTXO? Officially interpreted as: unspent trade output, which is the most basic unit of bitcoin transactions. bitcoin transactions consist of transaction input and transaction output, each of which costs an input, produces an output, and the output is "unspent trade output," which is UTXO.

简单解释下:小张给小李要转5个比特币,那怎样这个交易才算有效的呢?就是小张手里存在这5个比特币,也就是说这5个比特币还没有被小张花出去过,还没有交易过。这时这5个比特币转移的过程才能叫做未花费过的交易输出。

Just to explain: how can this deal be effective if Xiao Zhang transfers five bitcoins to Xiao Li? The five bitcoins are in Xiao Zhang’s hands, which means that the five bitcoins have not been spent or traded. This is when the five bitcoins transfer process can be called unspent transactions.

假如在之前小张已经把这5个比特币用私钥转给别人了,这个交易信息就会被记录验证,此时,小张要再想给小李转这5个比特币,就转不成了,因为属于花费过的交易额了。这样就有效防止了多重支付的问题。

If Jang had already transferred the five bitcoins to someone else before, the transaction information would have been recorded, and at that point, Chang would have been unable to transfer the five bitcoins to Li, because it was the amount of transactions that had been spent. That effectively prevented the problem of multiple payments.

所以你也可以把UTXO简单理解为你口袋里有效的那些零钱,这些零钱可以作交易使用。

So you can simply understand UTXO as the change that works in your pocket, which can be traded.

END:写在最后

概括说,比特币挖矿就是人们参与维护比特币数据库,从而得到比特币奖励。比特币一开始作为虚拟货币,本没有价值,但当越来越多人参与一项有意义的工作时,获得报酬,这个报酬载体也就被赋予了价值,其实也正是人们的共识才赋予了它的价值。

In summary, bitcoin mining is the involvement of people in the maintenance of bitcoin databases, thereby receiving bitcoin rewards. bitcoin was initially worthless as a virtual currency, but when more and more people are involved in a meaningful job, the compensation vehicle is given value, and it is the consensus that gives it value.

就像我们工作,获得钞票一样,只不过,钞票是被国家强制规定的一种价值载体,而比特币是人们自发承认有价值的载体。至于是否持续具有价值,还需要更强大的共识力量~

Just as we work and get the money, it's just that it's a value carrier that the state enforces, and bitcoin is a vehicle that people automatically recognize as valuable. There's a need for a stronger consensus if it's to be of sustainable value.

文字格式和图片示例

注册有任何问题请添加 微信:MVIP619 拉你进入群

弹窗与图片大小一致 文章转载注明 网址:https://netpsp.com/?id=69974

美化布局示例

欧易(OKX)最新版本

【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   全球官网 大陆官网

币安(Binance)最新版本

币安交易所app【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址

火币HTX最新版本

火币老牌交易所【遇到注册下载问题请加文章最下面的客服微信】永久享受返佣20%手续费!

APP下载   官网地址
可以去百度分享获取分享代码输入这里。
声明

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

发表评论
平台列表
美化布局示例

欧易(OKX)

  全球官网 大陆官网

币安(Binance)

  官网

火币(HTX)

  官网

Gate.io

  官网

Bitget

  官网

deepcoin

  官网
关注我们

若遇到问题,加微信客服---清歌

搜索
排行榜
扫一扫,加我为微信好友加我为微信好友