区块链的基本概念和原理是什么,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。
一、区块链的本质、原理
区块链(Blockchain)是指通过去中心化和去信任的方式集体维护一个可靠数据库的技术方案。
Block chain (Blockchain) refers to a technical programme for the collective maintenance of a reliable database through decentralisation and detrust.
什么叫去中心化?例如公司里有服务器,所有的数据都存储在服务器上,或者云服务器上,那么这就是一个中心化的系统。又例如公司账务结算,通过银行汇入和汇出,那么银行就是充当中心化的这么一角色。去中心化就是要消除中心化这么一个角色,那么有人会问,没有了服务器这样一种存储数据的媒介,数据是如何存储和交换的呢?
What's decentralisation? For example, the company has
二、区块链的运行
(1)节点
在区块链系统中,节点是组成区块链的基本单元。在有些区块链系统中,任何加入区块链的设备,比如手机、PC、电子设备都可以是一个节点。
In block chain systems, nodes are the basic units that form the block chain. In some block chain systems, any device that joins the block chain, such as mobile phones, PCs, electronic devices, can be a node.
节点分为验证节点和非验证节点。验证节点就是指参与共识的一些节点,非验证节点就是无共识权限的节点。什么是共识?
Nodes are divided into validation nodes and non-verification nodes. Validation nodes refer to points participating in consensus, and non-verification nodes are nodes without consensus authority. What is consensus?
(2)共识算法
有了节点和共识节点,那么就要有一套算法,按照这个算法去验证交易的合法性,防止恶意交易。就好比选举总统,人人都有选举权,那么选举候选人当总统就必须有一套章程,是按照票数最高的人当总统,还是按照州投票数最高的候选人当总统,这就是一套共识算法。按照这套章法选举出来的总统是公正的,不可抵赖。同样的,共识节点通过一套共识算法而产生的区块是不可更改,不可逆的。所以区块链上的数据一旦生成和记录,就不可以修改。这样就可以保证数据的合法性,并且公开,透明。
With nodes and nodes of consensus, there will be an algorithm to verify the legitimacy of the transaction and to prevent bad-faith transactions. As with the election of the president, everyone has the right to vote, the election of a candidate to the presidency would require a set of by-laws, based on the highest number of votes, or the highest number of candidates to vote in the state, which is a consensus algorithm. The election of a president under this code is fair and indefensible.
共识算法的种类:PBFT、PoW、Pos等。比特币是用的Pow(工作量证明算法)共识,通过算力计算。PBFT是拜占庭容错算法,若区块链上有3N+1个节点,那么最大的恶意节点数不能超过N个,这里设计到一个经典的算法,拜占庭将军问题,本篇暂不对这个问题进行讲解。作者当初在学习研究时用的是noop算法,是一套“假”的共识算法。其他一些共识算法比如PoS(Proof of Stake,权益证明)、DPoS(Delegate Proof of Stake,委托权益证明)、Ripple(瑞波)等。
Consensus algorithms: PBFT, PoW, Pos, etc.. Bitcoin is a Pow (calendum proof algorithm) consensus, calculated by force of law. PBFT is a Byzantine aptness algorithm, and if there are 3N+1 nodes in the chain of blocks, the maximum number of malicious nodes cannot exceed N. It is designed to be a classic algorithm, General Byzantine’s problem, and the present book is silent on this issue. The author’s study was based on a noop algorithm, a “false” consensus algorithm. Some other consensus algorithms such as PoS (Proof of Starke, certificate of interests), DPoS (Delegate Proof of Starke, commission certificate of interests), Ripple, etc.
(3)区块
当共识节点按照某个共识算法一致通过后,就会在区块链上广播通知所有的节点,广播完成之后就会生成一个新的区块,区块链就是由一个一个的区块链接组成的。
When consensus nodes are unanimously adopted according to a consensus algorithm, all nodes are reported on the block chain, and a new block is created when the broadcast is completed, consisting of a link to one block.
区块的数据结构如上图,包含:前一区块的Hash,当前区块的Hash、时间戳以及交易相关的数据。
The data structure of the blocks, as shown above, includes: Hash of the previous block, Hash of the current block, time stamp and transaction-related data.
当一个区块生成后,就永久保存在区块链中了,所有的节点都权限去访问这个区块的数据,这样就做到公开化,透明化,不会因为恶意操作或者其他因素去篡改数据。达到相互之间信任的目的。
When a block is created, it is permanently stored in the chain of blocks, and all nodes are given access to the data of the block, so that it is open and transparent and does not distort the data because of malicious operations or other factors.
(4)链码(chaincode)
链码又叫智能合约,当我们在区块链上发起交易或者查询交易时,就需要一定的规则进行交易。智能合约一般是由程序员写,写好之后部署到区块链上,相应的交易就可以按照这个智能合约进行。就好比企业之间的合同签订。
The chain code is called smart contracts, and when we start a transaction on a block or search for a transaction, there are rules to deal with. Smart contracts are usually written by programmers and then deployed on a block chain, and the corresponding transaction can be made in accordance with this smart contract.
chaincode可以由go、nodejs等编写。作者当初用的是go,编写好后部署到IBM的fabric系统上。对外提供有query、invoke等接口。
The author used Go, which was prepared for deployment to IBM’s Fabric system. The interfaces are query, invoke, etc.
三,区块链的划分
区块链按照性质可划分为公有链、私有链、联盟链。
Block chains can be divided by nature into public, private and union chains.
(1)公有链
在公有链上,任何个人都可以加入,对数据进行读写和交易,权限的门槛比较低。比较著名公有链应用比如比特币。公有链有数据公开并且透明性、匿名性、访问门槛低等特点。当公有链上的区块达到一定数量时,访问的速度会降低。这也是公有链的弊端。
On the public chain, any individual can join, and the data can be read and written and traded, with lower thresholds of authority. More famous public chain applications, such as Bitcoin, have features such as data openness and transparency, anonymity, and low access thresholds. When the number of blocks on the public chain reaches a certain number, the speed of access decreases. This is also the disadvantage of the public chain.
(2)私有链
与公有链相反,私有链是一种非“公开”的链,一般用于企业内部,需要授权才能加入节点。加入的节点一般有访问数据的权限,而写入权限被严格控制。例如蚂蚁金服,就是比较知名的私有链应用。
Contrary to the public chain, the private chain is a non- “public” chain that is generally used within the enterprise and requires authorization to add nodes. The added nodes usually have access to data, while writing rights are strictly controlled. For example, an ant gold jacket is a more well-known private chain application.
私有链有交易速度快、私密性好、交易成本低、安全性高等特点。弊端是少数节点有权限、数据容易被操控、代码易被修改等。
Private chains have the characteristics of speed, privacy, low transaction costs, and high security. The disadvantages are that a few nodes have access, data are easily manipulated, codes are easily modified, etc.
(3)联盟链
联盟链是由不同的机构或组织共同管理的区块链,只有经过授权后才能加入和退出,每个机构或组织管理一个或几个节点。每个机构或组织有实体机构组织。联盟链适合组织机构间的交易和结算。
The chain of alliances is a block chain that is jointly managed by different institutions or organizations and can only be joined and withdrawn with authorization, with each agency or organization managing one or more nodes.
比较知名的有中国区块链研究联盟(CBRA)和微众银行等。
More prominent are the China Block Chain Research Alliance (CBRA) and Microbanks, among others.
关于区块链的基本概念和原理是什么问题的解答就分享到这里了,希望以上内容可以对大家有一定的帮助,如果你还有很多疑惑没有解开,可以关注亿速云行业资讯频道了解更多相关知识。
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论