錯誤:AcceptBlock:高雜湊,工作證明失敗(程式碼 16)
我按照這個中等連結創建了一個像比特幣一樣的硬幣。<https://medium.com/@jordan.baczuk/how-to-fork-bitcoin-c39139506443>
根據本教程,我更新
DEFAULT_MAX_TIP_AGE
到int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE * 4000;
但它不起作用,我無法探勘塊,但是當我添加-maxtipage=432000000
到我的命令行守護程序然後探勘工作時,我能夠探勘創世塊。但後來我想如果我能創建自己的創世塊會更好。所以我點擊了這個連結:如何創建一個新的創世塊?
我對
pszTimestamp
、nTime
和nNonce
、hashGenesisBlock
和進行了更改hashMerkleRoot
。我能夠毫無問題地執行守護程序
assert
。首先我得到了這個錯誤錯誤:ReadBlockFromDisk:CBlockDiskPos(nFile=0,nPos=8)2018-11-08T10:12:47Z 處的塊頭錯誤 *** 讀取塊失敗
然後在使用
-reindex
. 以前的錯誤消失了,但出現了新的錯誤錯誤:AcceptBlock:高雜湊,工作證明失敗(程式碼 16)
我該如何解決這個問題
編輯: 根據@JBaczuk 給出的建議。我使用 genesisgen 生成區塊資訊
<https://github.com/liveblockchain/genesisgen>
CMD 語法:
./genesis [options] <pubkey> "<timestamp>" <nBits> <startNonce> <unixtime>
我的命令:
./genesis 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches" 486604799 2083236893 1541690605
輸出:
nBits: 0x1d00ffff startNonce: 2083236893 unixtime: 1541690605 Coinbase: 04ffff001d01044c504e4454562030382f4e6f762f3230313820496e6469612057616e747320546f204c6f63616c6c79204d616e75666163747572652c204578706f72742042756c6c657420547261696e20436f6163686573 PubkeyScript: 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac Merkle Hash: 94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d Byteswapped: 5d899d6099e42acc9a8d97197e834ed7d98adebbced63aadcc399b76c7efb494 Generating block... 124397 Hashes/s, Nonce 20632283897 Block found! Hash: 000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672 Nonce: 2063257030 Unix time: 1541690608
程式碼變化:
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward) { const char* pszTimestamp = "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches"; const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG; return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward); }
…… …… ……
genesis = CreateGenesisBlock(1541690608, 2063257030, 0x1d00ffff, 1, 50 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); assert(consensus.hashGenesisBlock == uint256S("0x000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672")); assert(genesis.hashMerkleRoot == uint256S("0x94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d"));
我得到了這個斷言錯誤:
chainparams.cpp:125: CMainParams::CMainParams(): Assertion `genesis.hashMerkleRoot == uint256S("0x94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d")' failed. Aborted (core dumped)
這是因為您沒有探勘該區塊,即您沒有搜尋導致區塊雜湊小於主網
powLimit
中定義的(初始難度目標)的src/chainparams.cpp
consensus.powLimit("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
隨機數。去做這個:序列化塊頭。連接(按此順序,小端,十六進制格式)版本、前一個塊雜湊、默克爾根、unix 紀元時間、難度目標(位)和隨機數。然後計算 HASH256 或 SHA256(SHA256())。如果不小於
powLimit
你必須更改nonce並重試,一直這樣做直到你成功,這就是挖礦。有一些腳本可以做到這一點,例如:https ://github.com/liveblockchain/genesisgen
更新(來自上述問題的範例):
的範例用法
genesisgen
./genesis [options] <pubkey> "<timestamp>" <nBits> <startNonce> <unixtime> ./genesis 04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f "NDTV 08/Nov/2018 India Wants To Locally Manufacture, Export Bullet Train Coaches" 486604799 2083236893 1541690605 nBits: 0x1d00ffff startNonce: 2083236893 unixtime: 1541690605 Coinbase: 04ffff001d01044c504e4454562030382f4e6f762f3230313820496e6469612057616e747320546f204c6f63616c6c79204d616e75666163747572652c204578706f72742042756c6c657420547261696e20436f6163686573 PubkeyScript: 4104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac Merkle Hash: 94b4efc7769b39ccad3ad6cebbde8ad9d74e837e19978d9acc2ae499609d895d Byteswapped: 5d899d6099e42acc9a8d97197e834ed7d98adebbced63aadcc399b76c7efb494 Generating block... 124397 Hashes/s, Nonce 20632283897 Block found! Hash: 000000004c7d908bd3c911a21b849d3cdca124131d2fb8a1af009698742ad672 Nonce: 2063257030 Unix time: 1541690608
您需要在斷言中使用 Byteswapped merkle root 和塊雜湊,並在創世塊創建函式中使用新發現的 nonce。