首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

大狗精读区块链白皮书之比特币(六)——Network

本文由币乎社区(http://bihu.com)内容支持计划奖励。

在Transactions、Timestamp Server、Proof-of-Work三节的基础上,Network这一节阐述了区块链网络的运行机理。可以说,精读完这四节,我们就初步的「入门」了比特币系统的框架。白皮书接下来的大部分内容可以算做对这个框架的深入与补充。

注:前几篇的「图解区块链」是某个知识点的图解,但本篇的「图解区块链」是Network整节的图解。

四个章节构成了比特币系统框架的入门版

1 译文

运行网络的步骤如下:

1)新的交易广播给全节点。

2)每一个节点将新交易收集到一个区块内。

3)每个节点为它的区块寻找到一个具有足够难度的工作量证明。

4)当节点找到了这个「工作量证明」的时候,它将这个区块广播给所有的节点。

5)仅当区块中所有的交易都是有效的且之前未存在过时,所有的节点接受该区块。

6)所有的节点表示接受该区块的方式是——在链上创造下一个区块,将已接受的区块的hash值作为前一个hash值(hashPrevBlock)。

节点总认为最长的链即是正确的那一个,同时将对它进行延长。假如两个节点同时广播下一个区块的不同版本,有一些节点将会比另一个更早的接收其中一个。在这种情况下,它们在第一个接收到的节点的基础上进行工作,但是保存另一个分支,以防另一个分支变得更长。当下一个「工作量证明」被找到,一个分支变得更长时,僵局会被打破——那些曾经在某分支上工作的节点会转而选择更长的那个。

「新交易的广播」没有必要到达所有的节点。只要交易信息能够抵达足够多的节点,那么它们将很快被整合进一个区块中。区块广播对于丢失的信息具有一定的容错度。如果一个节点没有接收到区块A,当它接收到下一个区块,然后发现自己漏掉了区块A时,也可以自己提出下载区块A的请求。

2 图解区块链—比特币网络是如何运作的?

(1)假设一个网络中存在ABCD四个节点。

(2)发生了三笔交易,交易被广播给ABC三个节点。但是节点D现在不在线,所以没有接收到~

(3)ABC三个节点开始「挖矿」,也就是找Nounce啦。

(4)节点A率先找到了Nounce,将区块成功打包。

(5)节点A将打包好的区块(图上标记为区块A)广播给其它节点。

(6)其它节点确认没有「双重支付」等问题后接受该区块,接受的方式为链上这个区块后再在这个区块后链一个区块(后一个区块在图上标记为区块4)。

(7)D节点上线了。这时候C节点向D节点发送区块4的时候,D节点会发现少了一个区块,它便向其它节点请求:「给我那个漏掉的区块!」

(8)特殊情况!如果同时收到下一区块的两个版本(区块A与区块B),那么选择哪一个区块取决于下下个区块是基于「区块A」的还是基于「区块B」的延长。

3 原文

The steps to run the network are as follows:

1) New transactions are broadcast to all nodes.

2) Each node collects new transactions into a block.

3) Each node works on finding a difficult proof-of-work for its block.

4) When a node finds a proof-of-work, it broadcasts the block to all nodes.

5) Nodes accept the block only if all transactions in it are valid and not already spent.

6) Nodes express their acceptance of the block by working on creating the next block in the chain, using the hash of the accepted block as the previous hash.

Nodes always consider the longest chain to be the correct one and will keep working on extending it. If two nodes broadcast different versions of the next block simultaneously, some nodes may receive one or the other first. In that case, they work on the first one they received, but save the other branch in case it becomes longer.The tie will be broken when the next proofof-work is found and one branch becomes longer;the nodes that were working on the other branch will then switch to the longer one.

New transaction broadcasts do not necessarily need to reach all nodes.As long as they reach many nodes, they will get into a block before long. Block broadcasts are also tolerant of dropped messages. If a node does not receive a block, it will request it when it receives the next block and realizes it missed one.

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180201G1E4V600?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券