aboutsummaryrefslogtreecommitdiff
path: root/src/miner.cpp
diff options
context:
space:
mode:
authorNell Hardcastle <[email protected]>2014-04-10 21:36:05 -0700
committerPatrick Lodder <[email protected]>2014-08-01 16:43:05 +0200
commit5da72d7da85c4feb30c9de8f88aa59daffb903d0 (patch)
tree15767d67342fa3984f99fd4881caefb05bf2cf17 /src/miner.cpp
parentSupport auxillary proof of work. (diff)
downloaddiscoin-5da72d7da85c4feb30c9de8f88aa59daffb903d0.tar.xz
discoin-5da72d7da85c4feb30c9de8f88aa59daffb903d0.zip
Enable RPC commands for mining aux proof of work blocks.
Diffstat (limited to 'src/miner.cpp')
-rw-r--r--src/miner.cpp30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/miner.cpp b/src/miner.cpp
index 6a1f36872..5de11039a 100644
--- a/src/miner.cpp
+++ b/src/miner.cpp
@@ -12,6 +12,7 @@
#include "main.h"
#include "net.h"
#include "scrypt.h"
+#include "auxpow.h"
#ifdef ENABLE_WALLET
#include "wallet.h"
#endif
@@ -472,12 +473,31 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
uint256 hash = pblock->GetPoWHash();
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
- if (hash > hashTarget)
- return false;
+ CAuxPow *auxpow = pblock->auxpow.get();
- //// debug print
- LogPrintf("DogecoinMiner:\n");
- LogPrintf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
+ if (auxpow != NULL) {
+ if (!auxpow->Check(pblock->GetHash(), pblock->GetChainID()))
+ return error("AUX POW is not valid");
+
+ if (auxpow->GetParentBlockHash() > hashTarget)
+ return error("AUX POW parent hash %s is not under target %s", auxpow->GetParentBlockHash().GetHex().c_str(), hashTarget.GetHex().c_str());
+ //// debug print
+ printf("DogecoinMiner:\n");
+ printf("AUX proof-of-work found \n our hash: %s \n parent hash: %s \n target: %s\n",
+ hash.GetHex().c_str(),
+ auxpow->GetParentBlockHash().GetHex().c_str(),
+ hashTarget.GetHex().c_str());
+ }
+ else
+ {
+ if (hash > hashTarget)
+ return false;
+
+ //// debug print
+ printf("DogecoinMiner:\n");
+ printf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
+ }
+
pblock->print();
LogPrintf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str());