aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/chain.h17
-rw-r--r--src/dogecoin.cpp6
-rw-r--r--src/main.cpp5
-rw-r--r--src/txdb.cpp14
4 files changed, 32 insertions, 10 deletions
diff --git a/src/chain.h b/src/chain.h
index c735f6a70..359a14771 100644
--- a/src/chain.h
+++ b/src/chain.h
@@ -111,6 +111,9 @@ public:
//! pointer to the index of some further predecessor of this block
CBlockIndex* pskip;
+ //! pointer to the AuxPoW header, if this block has one
+ boost::shared_ptr<CAuxPow> pauxpow;
+
//! height of the entry in the chain. The genesis block has height 0
int nHeight;
@@ -145,6 +148,9 @@ public:
unsigned int nBits;
unsigned int nNonce;
+ // Dogecoin: Keep the Scrypt hash as well as SHA256
+ uint256 hashBlockPoW;
+
//! (memory only) Sequential id assigned to distinguish order in which blocks are received.
uint32_t nSequenceId;
@@ -153,6 +159,7 @@ public:
phashBlock = NULL;
pprev = NULL;
pskip = NULL;
+ pauxpow.reset();
nHeight = 0;
nFile = 0;
nDataPos = 0;
@@ -168,6 +175,7 @@ public:
nTime = 0;
nBits = 0;
nNonce = 0;
+ hashBlockPoW = uint256();
}
CBlockIndex()
@@ -184,6 +192,7 @@ public:
nTime = block.nTime;
nBits = block.nBits;
nNonce = block.nNonce;
+ hashBlockPoW = block.GetPoWHash();
}
CDiskBlockPos GetBlockPos() const {
@@ -309,6 +318,14 @@ public:
READWRITE(nTime);
READWRITE(nBits);
READWRITE(nNonce);
+ READWRITE(hashBlockPoW);
+ if (this->nVersion.IsAuxpow()) {
+ if (ser_action.ForRead())
+ pauxpow.reset(new CAuxPow());
+ assert(pauxpow);
+ READWRITE(*pauxpow);
+ } else if (ser_action.ForRead())
+ pauxpow.reset();
}
uint256 GetBlockHash() const
diff --git a/src/dogecoin.cpp b/src/dogecoin.cpp
index 6916982e0..2443732b2 100644
--- a/src/dogecoin.cpp
+++ b/src/dogecoin.cpp
@@ -113,12 +113,6 @@ bool CheckAuxPowProofOfWork(const CBlockHeader& block, const Consensus::Params&
if (!block.nVersion.IsAuxpow())
return error("%s : auxpow on block with non-auxpow version", __func__);
- /* Temporary check: Disallow parent blocks with auxpow version. This is
- for compatibility with the old client. */
- /* FIXME: Remove this check with a hardfork later on. */
- if (block.auxpow->getParentBlock().nVersion.IsAuxpow())
- return error("%s : auxpow parent block has auxpow version", __func__);
-
if (!block.auxpow->check(block.GetHash(), block.nVersion.GetChainId(), params))
return error("%s : AUX POW is not valid", __func__);
if (!CheckProofOfWork(block.auxpow->getParentBlockPoWHash(), block.nBits, params))
diff --git a/src/main.cpp b/src/main.cpp
index dfcd50310..80d301d54 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2531,6 +2531,11 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block)
pindexNew->BuildSkip();
}
pindexNew->nChainWork = (pindexNew->pprev ? pindexNew->pprev->nChainWork : 0) + GetBlockProof(*pindexNew);
+ // Dogecoin: Add AuxPoW
+ if (block.nVersion.IsAuxpow()) {
+ pindexNew->pauxpow = block.auxpow;
+ assert(NULL != pindexNew->pauxpow.get());
+ }
pindexNew->RaiseValidity(BLOCK_VALID_TREE);
if (pindexBestHeader == NULL || pindexBestHeader->nChainWork < pindexNew->nChainWork)
pindexBestHeader = pindexNew;
diff --git a/src/txdb.cpp b/src/txdb.cpp
index bdc67a049..7eb857ed5 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -213,6 +213,7 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
// Construct block index object
CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash());
pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev);
+ pindexNew->pauxpow = diskindex.pauxpow;
pindexNew->nHeight = diskindex.nHeight;
pindexNew->nFile = diskindex.nFile;
pindexNew->nDataPos = diskindex.nDataPos;
@@ -224,11 +225,16 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
pindexNew->nNonce = diskindex.nNonce;
pindexNew->nStatus = diskindex.nStatus;
pindexNew->nTx = diskindex.nTx;
+ pindexNew->hashBlockPoW = diskindex.hashBlockPoW;
- /* Bitcoin checks the PoW here. We don't do this because
- the CDiskBlockIndex does not contain the auxpow.
- This check isn't important, since the data on disk should
- already be valid and can be trusted. */
+ if (pindexNew->nVersion.IsAuxpow()) {
+ if (!diskindex.pauxpow->check(diskindex.GetBlockHash(), pindexNew->nVersion.GetChainId(), Params().GetConsensus(pindexNew->nHeight))) {
+ return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
+ }
+ } else {
+ if (!CheckProofOfWork(pindexNew->hashBlockPoW, pindexNew->nBits, Params().GetConsensus(pindexNew->nHeight)))
+ return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
+ }
pcursor->Next();
} else {