首页 > 解决方案 > What if two blocks complete their POW at same time

问题描述

Let's consider a scenario: suppose 2 miners pick up 2 different unconfirmed transactions and they complete the proof of work. If miner A adds the block first to blockChain then the block produced by miner B be will be wrong/useless because the last_Hash he used is now wrong and he has to use the last_hash of miner A that is added right a second before he was going to add his block. e.g.

 

 <b>current chian: block1--block2--block3</b>
    <table>
    	<tr>
           		<td>Miner A  </td>
          		<td>Miner B</td>
    	</tr>
    	<tr>
    		<td>LastHast=block3-hash<br>				
    		currentHast=SHA(block3's_hash,timestemp,data,nonce)		<br>
    		proof of work		<br>				
    		add---- Successfully add block4	<br>
    		</td>	
       
    		<td>LastHast=block3-hash<br>				
    		currentHast=SHA(block3's_hash,timestemp,data,nonce)	<br>
    		proof of work		<br>				
    		add---- Fail because the last hash is now block4's not block3's So currentHash is wrong so the proof of work<br>
    		</td>
    	</tr>
    </table>

**
**

标签: blockchainbitcoin

解决方案


有效交易总是在最长的链上,最长的,我的意思是块数更大。

如果矿工 A和矿工 B 同时完成 PoW,进行分叉

目前,minerAminerB的交易都存储在 fullnode 上,fullnode 正在等待下一个区块的产生。

在下一个出块时间内,minerA先完成 PoW,然后minerA上的分叉(数据链)被认为更长,因此minerA成为最长的链并被认为是有效的,minerB上的块被认为是无效的,并被丢弃。


推荐阅读