论文学习 - Bitcoin:A Peer-to-Peer Electronic Cash System(4)

比特币:一个点对点的电子货币系统

5. 网络

5 Network
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 proof-of-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.

运行网络的步骤如下:

  1. 新交易向所有节点广播。
  2. 每个节点将新交易收集到一个区块。
  3. 每个节点为它的区块寻找工作量证明(困难)。
  4. 当一个节点找到了工作量证明,就向所有节点广播这个区块。
  5. 节点只有在区块内所有交易都是有效的且之前没有被支付的情况下接收这个区块。
  6. 节点通过使用这个区块的哈希值作为上一个哈希值,在链中创建下一个区块的方式表示对这个区块的接受。

节点总是认为最长的链为正确的并持续致力于延长它。如果两个节点同时广播了不同的下一个区块,有些节点可能先收到其中一个而其他节点先收到另一个。这种情况,节点基于他们收到的第一个区块工作,但是也保存另一个分支以防它变为更长的链。当下一个工作量证明被找到后僵局就会被打破,从而其中一个分支变得更长;在另一个分支上工作的节点将切换到更长的链上来。

新交易的广播不必到达所有的节点。只要到达一些节点,不久就会进入到一个区块。区块广播也是能容忍消息丢失的。如果一个节点没有收到某个区块,它将在收到下一个区块时发现它丢失了一个区块然后去请求这个区块。

【关注点】:

  • 另一个分支上工作的节点将切换到更长的链,也就意味着有些交易会失效,对于这些失效的交易如何处理?
  • 不久就会进入到一个区块,这个是指这笔交易会被保存到区块里。那一个区块会包含多少笔交易呢?

请我喝杯咖啡吧~

支付宝
微信