什么是区块链?
what is a block chain #xff1f;
区块链,英文?Blockchain,本质上是一种去中心化的分布式数据库。任何人只要架设自己的服务器,接入区块链网络,都可以成为这个庞大网络的一个节点。
Block chains & #xff0c; English? Blockchain, is essentially a distributed database that goes to centralizes. anyone who has their own server xff0c; access to block chain networks xff0c; can be a node in this vast network.
区块链既然本质是数据库,里面究竟存储了什么东西呢?让我们来了解一下区块链的基本单元:区块(Block)。
The block chain, since it is essentially a database xff0c; what exactly is stored in it xff1f; let's see the basic unit of the block chain xff1a; block xff08; Blockxff09; .
一个区块分为两大部分:
1.区块头?
区块头里面存储着区块的头信息,包含上一个区块的哈希值(PreHash),本区块体的哈希值(Hash),以及时间戳(TimeStamp)等等。
2.区块体
区块体存储着这个区块的详细数据(Data),这个数据包含若干行记录,可以是交易信息,也可以是其他某种信息。
刚才提及的哈希值又是什么意思呢?
想必大家都听说过MD5,MD5就是典型的哈希算法,可以把一串任意长度的明文转化成一串固定长度(128bit)的字符串,这个字符串就是哈希值。
而在我们的区块链中,采用的是一种更为复杂的哈希算法,叫做SHA256。最新的数据信息(比如交易记录)经过一系列复杂的计算,最终会通过这个哈希算法转化成了长度为256bit的哈希值字符串,也就是区块头当中的Hash,格式如下:
a8fdc205a9f19cc1c7507a60c4f01b13d11d7fd0
区块与Hash是一一对应的,Hash可以当做是区块的唯一标识。
不同的区块之间是如何进行关联的呢?依靠Hash和PreHash来关联。每一个区块的PreHash和前一个区块的Hash值是相等的。
什么是挖矿?
what's mining? #xff1f;
为什么要计算区块的哈希值呢?
Why do you calculate the Hashi value of blocks?
既然区块链是一个链状结构,就必然存在链条的头节点(第一个区块)和尾节点(最后一个区块)。一旦有人计算出区块链最新数据信息的哈希值,相当于对最新的交易记录进行打包,新的区块会被创建出来,衔接在区块链的末尾。
Since the block chain is a chain structure xff0c; there must be the first node of the chain xff08; the first node xff09; and the last node xff08; the last node xff09; xff0c; once the latest data information on the block chain is calculated, the Hashi value xff0c; the equivalent of packing the latest transaction log xff0c; the new block will be created xff0c; it will be connected at the end of the block chain.
新区块头的Hash就是刚刚计算出的哈希值,PreHash等于上一个区块的Hash。区块体的Data存储的是打包前的交易记录,这部分数据信息已经变得不可修改。
The Hash on the head of the new block is the Hashi value xff0c; PreHash is the same as the Hash on the previous block. The Data on the block is a record of transactions before packing xff0c; this part of the data information has become unalterable.
这个计算Hash值,创建新区块的过程就叫做挖矿。
用于进行海量计算的服务器,叫做矿机。
Server & #xff0c; called miner for volume calculations.
操作计算的工作人员,叫做矿工。
Worker & #xff0c; called Miner .
计算哈希值究竟难在哪里?咱们来做一个最粗浅的解释,哈希值计算的公式如下:
Where it is difficult to calculate Hashi's value xff1f; let's do one of the crudest explanations xff0c; the Hashi's formula is as follows xff1a;
Hash = SHA-256(最后一个区块的Hash + 新区块基本信息 + 交易记录信息 + 随机数)
其中,交易记录信息也是一串哈希值,它的计算涉及到一个数据结构?Merkle Tree。有兴趣的小伙伴可以查阅相关资料,我们暂时不做展开介绍。
Among them is xff0c; transaction log information is also a barrage of xff0c; its calculation involves a data structure?
这里关键的计算难点在于随机数的生成。猥琐的区块链发明者为了增大Hash的计算难度,要求Hash结果的前72bit必须都是0,这个几率实在是太小太小。
The key difficulty here is the generation of random numbers. In order to make Hash more difficult to calculate #xff0c; the pre-72bi t, which requires Hash results, must all be 0 and #xff0c; this is a very small probability.
由于(最后一个区块的Hash + 新区块基本信息 +?交易记录信息)是固定的,所以能否获得符合要求的Hash,完全取决于随机数的值。挖矿者必须经过海量计算,反复生成随机数进行“撞大运”一般的尝试,才有可能得到正确的Hash,从而挖矿成功。
Because xff08; Hash & #43 of the last block; New Block Basic Information & #43;? Transaction Record Information xff09; Fixed xff0c; Whether to obtain Hash, totally dependent on random numbers. The diggers must pass through the sea to calculate xff0c; Repeated attempts to generate random numbers for xff0c; it is possible to obtain the right Hash, and thus successful mining.
同时,区块头内还包含着一个动态的难度系数,当全世界的硬件计算能力越来越快的时候,区块链的难度系数也会水涨船高,使得全网平均每10分钟才能产生出一个新区块。
At the same time xff0c; there is a dynamic difficulty factor xff0c in the block; xff0c when hardware computing is increasing worldwide; the difficulty factor in the block chain is also high xff0c; and the net average of can produce a new block.
小伙伴们明白挖矿有多么难了吧?需要补充的是,不同的区块链应用在细节上是不同的,这里所描述的挖矿规则是以比特币为例。
Little partners understand how difficult it is to dig; what needs to be added is & #xff0c; different block chains are applied differently in detail & #xff0c; here the rules of mining are described in bitcoin, for example.
区块链的应用
block chain application
比特币(BitCoin)的概念最初由中本聪于2008年提出,而后根据这一思路设计发布了开源软件以及建构其上的P2P网络。比特币是一种P2P形式的数字货币。点对点的传输意味着一个去中心化的支付系统。
什么是P2P网络呢?
传统的货币都是由中央银行统一发行,所有的个人储蓄也是由银行统一管理,这是典型的中心化系统。
而比特币则是部署在一个全世界众多对等节点组成的去中心化网络之上。每一个节点都有资格对这种数字货币进行记录和发行。
至于比特币底层的数据存储,正是基于了区块链技术。比特币的每一笔交易,都对应了区块体数据中的一行,简单的示意如下:
交易记录的每一行都包含时间戳、交易明细、数字签名。
Each line of the transaction record contains a time stamp, a breakdown of the transaction, and a digital signature.
表格中只是为了方便理解。实际存储的交易明细是匿名的,只会记录支付方和收款方的钱包地址。
The details of the transactions actually stored are anonymous xff0c; only the wallet address of the payer and the payee is recorded .
至于数字签名呢,可以理解为每一条单笔交易的防伪标识,由非对称加密算法所生成。
As for digital signatures & #xff0c; understood as a security mark for each single transaction & #xff0c; generated by asymmetric encryption algorithms.
接下来说一说比特币矿工的奖励:
Let's move on to the bitcoin miners' reward #xff1a.
比特币协议规定,挖到新区块的矿工将获得奖励,从2008年起是50个比特币,然后每4年减半,目前2018年是12.5个比特币。流通中新增的比特币都是这样诞生的,也难怪大家对挖掘比特币的工作如此趋之若鹜!
The Bitcoin agreement provides xff0c; miners who dig into new blocks will be rewarded xff0c; 50bitcoinxff0c from 2008; and then halved every four years xff0c; currently 12.5 bitcoins in 2018. The new bitcoins in circulation are born like this xff0c; no wonder the process of digging bitcoins is so progressive xff01;
区块链的优势和劣势
The advantages and disadvantages of the block chain
区块链的优势:
1.去中心化
1. Go to the center
区块链不依赖于某个中心节点,整个系统的数据由全网所有对等节点共同维护,都可以进行数据的存储和检验。这样一来,除非攻击者黑掉全网半数以上的节点,否则整个系统是不会遭到破坏的。
Block chains are not dependent on a central node & #xff0c; system-wide data are maintained by all peer-to-peer nodes of the network & #xff0c; data can be stored and tested. This way xff0c; the entire system will not be destroyed unless the attackers black out more than half of the node xff0c.
2.信息不可篡改
2. Information cannot be tampered with
区块内的数据是无法被篡改的。一旦数据遭到篡改哪怕一丁点,整个区块对应的哈希值就会随之改变,不再是一个有效的哈希值,后面链接的区块也会随之断裂。
The data in the block cannot be tampered with. Once the data has been tampered with even a little bit xff0c; the corresponding Hashi value of the block changes xff0c; it is no longer a valid Hashi xff0c; and the links to the blocks break down.
区块链的劣势:
1.过度消耗能源
1. Overconsumption of energy
想要生成一个新的区块,必须要大量服务器资源进行大量无谓的尝试性计算,严重耗费电能。
In order to generate a new block & #xff0c; a large number of server resources are required to make unnecessary experimental calculations & #xff0c; electricity is severely consumed.
2.信息的网络延迟
2. Information network delay
以比特币为例,任何一笔交易数据都需要同步到其他所有节点,同步过程中难免会受到网络传输延迟的影响,带来较长的耗时。
Take Bitcoin as an example & #xff0c; any transaction data need to be synchronized to all other nodes & #xff0c; the synchronization is inevitably affected by delay in network transmission & #xff0c; and it takes longer time.
几点补充:
several additions to #xff1a;
1.本漫画部分内容参考了阮一峰的博文《区块链入门教程》,感谢这位大神的科普。
1. Part of this comic book is based on the Boeing " #xff0c ", at the peak of Nguyen I; thanks the great god, Kopu.
2.由于篇幅有限,关于Merkle Tree?和?非对称加密?的知识暂时没有展开细讲,有兴趣的小伙伴们可以查阅资料进行更深一步的学习。
Due to space constraints xff0c; knowledge of Merkle Tree? and
—————END—————
IntelliJ IEA's interface debugging tool is extremely useful xff01;
欢迎关注,点个在看
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论