aboutsummaryrefslogtreecommitdiffstats
path: root/blockchain.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'blockchain.cpp')
-rw-r--r--blockchain.cpp36
1 files changed, 30 insertions, 6 deletions
diff --git a/blockchain.cpp b/blockchain.cpp
index 69ea8fa2..ccfd5772 100644
--- a/blockchain.cpp
+++ b/blockchain.cpp
@@ -75,6 +75,12 @@ bytes createBlockRLPFromFields(mObject& _tObj)
if (_tObj.count("extraData"))
rlpStream << importByteArray(_tObj["extraData"].get_str());
+ if (_tObj.count("seedHash"))
+ rlpStream << importByteArray(_tObj["seedHash"].get_str());
+
+ if (_tObj.count("mixBytes"))
+ rlpStream << importByteArray(_tObj["mixBytes"].get_str());
+
if (_tObj.count("nonce"))
rlpStream << importByteArray(_tObj["nonce"].get_str());
@@ -130,13 +136,17 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
{
// find new valid nonce
ProofOfWork pow;
- MineInfo ret;
- while (!ProofOfWork::verify(blockFromFields.headerHash(WithoutNonce), blockFromFields.nonce, blockFromFields.difficulty))
- tie(ret, blockFromFields.nonce) = pow.mine(blockFromFields.headerHash(WithoutNonce), blockFromFields.difficulty, 1000, true, true);
+ std::pair<MineInfo, Ethash::Proof> ret;
+ while (!ProofOfWork::verify(blockFromFields))
+ {
+ ret = pow.mine(blockFromFields, 1000, true, true); // tie(ret, blockFromFields.nonce)
+ Ethash::assignResult(ret.second, blockFromFields);
+ }
//update genesis block in json file
o["genesisBlockHeader"].get_obj()["stateRoot"] = toString(blockFromFields.stateRoot);
o["genesisBlockHeader"].get_obj()["nonce"] = toString(blockFromFields.nonce);
+ o["genesisBlockHeader"].get_obj()["mixBytes"] = toString(blockFromFields.mixBytes);
}
// create new "genesis" block
@@ -266,15 +276,25 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
if (blObj["blockHeader"].get_obj().count("extraData"))
tmp.extraData = importByteArray(blObj["blockHeader"].get_obj()["extraData"].get_str());
+ if (blObj["blockHeader"].get_obj().count("mixBytes"))
+ tmp.mixBytes = h256(blObj["blockHeader"].get_obj()["mixBytes"].get_str());
+
+ if (blObj["blockHeader"].get_obj().count("seedHash"))
+ tmp.seedHash = h256(blObj["blockHeader"].get_obj()["seedHash"].get_str());
+
// find new valid nonce
if (tmp != current_BlockHeader)
{
current_BlockHeader = tmp;
+
ProofOfWork pow;
- MineInfo ret;
- while (!ProofOfWork::verify(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.nonce, current_BlockHeader.difficulty))
- tie(ret, current_BlockHeader.nonce) = pow.mine(current_BlockHeader.headerHash(WithoutNonce), current_BlockHeader.difficulty, 10000, true, true);
+ std::pair<MineInfo, Ethash::Proof> ret;
+ while (!ProofOfWork::verify(current_BlockHeader))
+ {
+ ret = pow.mine(current_BlockHeader, 1000, true, true); // tie(ret, blockFromFields.nonce)
+ Ethash::assignResult(ret.second, current_BlockHeader);
+ }
}
}
else
@@ -302,6 +322,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
oBlockHeader["gasUsed"] = toString(current_BlockHeader.gasUsed);
oBlockHeader["timestamp"] = toString(current_BlockHeader.timestamp);
oBlockHeader["extraData"] = toHex(current_BlockHeader.extraData);
+ oBlockHeader["mixBytes"] = toString(current_BlockHeader.mixBytes);
+ oBlockHeader["seedHash"] = toString(current_BlockHeader.seedHash);
oBlockHeader["nonce"] = toString(current_BlockHeader.nonce);
blObj["blockHeader"] = oBlockHeader;
@@ -423,6 +445,8 @@ void doBlockchainTests(json_spirit::mValue& _v, bool _fillin)
BOOST_CHECK_MESSAGE(blockHeaderFromFields.gasUsed == blockFromRlp.gasUsed, "gasUsed in given RLP not matching the block gasUsed!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields.timestamp == blockFromRlp.timestamp, "timestamp in given RLP not matching the block timestamp!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields.extraData == blockFromRlp.extraData, "extraData in given RLP not matching the block extraData!");
+ BOOST_CHECK_MESSAGE(blockHeaderFromFields.mixBytes == blockFromRlp.mixBytes, "mixBytes in given RLP not matching the block mixBytes!");
+ BOOST_CHECK_MESSAGE(blockHeaderFromFields.seedHash == blockFromRlp.seedHash, "transactionsRoot in given RLP not matching the block transactionsRoot!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields.nonce == blockFromRlp.nonce, "nonce in given RLP not matching the block nonce!");
BOOST_CHECK_MESSAGE(blockHeaderFromFields == blockFromRlp, "However, blockHeaderFromFields != blockFromRlp!");