Go-Ethereum

如何讓私有鏈的乙太坊挖礦難度靜態化?

  • June 14, 2021

我已經在乙太坊中實現了私有鏈,但它的難度級別隨著時間的推移而增加,因此挖礦過程變慢了。是否可以將難度設為靜態或在測試網中禁用它。

修改CalcDifficultyin Geth 以返回一個靜態數字,然後重新建構 Geth。例子:

func CalcDifficulty(config *ChainConfig, time, parentTime uint64, parentNumber, parentDiff *big.Int) *big.Int {
   return big.NewInt(0x4000)
}

來源:對是否可以更改塊目標時間的回答

如果它是私有鏈,您可以difficulty在創世塊中定義。

像這樣的東西

{
 "nonce": "0x0000000000000042",
   "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
   "difficulty": "0x4000",
   "alloc": {},
   "coinbase": "0x0000000000000000000000000000000000000000",
   "timestamp": "0x00",
   "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
   "extraData": "Custem Ethereum Genesis Block",
   "gasLimit": "0xffffffff"
}

這是如何設置測試網的好讀物

引用自:https://ethereum.stackexchange.com/questions/7154