diff --git a/src/core.cpp b/src/core.cpp index be53fd08b..3980b5e94 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -8,12 +8,6 @@ #include "util.h" - -int GetOurChainID() -{ - return 0x0000; -} - std::string COutPoint::ToString() const { return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n); diff --git a/src/core.h b/src/core.h index 57642dcb0..d064bc868 100644 --- a/src/core.h +++ b/src/core.h @@ -28,23 +28,19 @@ int ReadWriteAuxPow(Stream& s, boost::shared_ptr& auxpow, int nType, in template int ReadWriteAuxPow(Stream& s, const boost::shared_ptr& auxpow, int nType, int nVersion, CSerActionGetSerializeSize ser_action); -enum -{ - // primary version - BLOCK_VERSION_DEFAULT = (1 << 0), +// primary version +static const int BLOCK_VERSION_DEFAULT = (1 << 0); +static const int BLOCK_VERSION_AUXPOW = (1 << 8); +static const int BLOCK_VERSION_CHAIN_START = (1 << 16); +static const int BLOCK_VERSION_CHAIN_END = (1 << 30); - // modifiers - BLOCK_VERSION_AUXPOW = (1 << 8), - - // bits allocated for chain ID - BLOCK_VERSION_CHAIN_START = (1 << 16), - BLOCK_VERSION_CHAIN_END = (1 << 30), -}; +static const int AUXPOW_CHAIN_ID = 0x0000; //TODO change me +static const int AUXPOW_START_MAINNET = INT_MAX; //TODO change me +static const int AUXPOW_START_TESTNET = 158100; /** No amount larger than this (in satoshi) is valid */ static const int64_t MAX_MONEY = 10000000000 * COIN; // Dogecoin: maximum of 100B coins (given some randomness), max transaction 10,000,000,000 inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } -int GetOurChainID(); /** An outpoint - a combination of a transaction hash and an index n into its vout */ class COutPoint @@ -403,7 +399,7 @@ public: void SetNull() { - nVersion = CBlockHeader::CURRENT_VERSION | (GetOurChainID() * BLOCK_VERSION_CHAIN_START); + nVersion = CBlockHeader::CURRENT_VERSION | (AUXPOW_CHAIN_ID * BLOCK_VERSION_CHAIN_START); hashPrevBlock = 0; hashMerkleRoot = 0; nTime = 0; diff --git a/src/main.cpp b/src/main.cpp index 2735fc6d4..9141f86b6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2356,9 +2356,9 @@ bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBl int GetAuxPowStartBlock() { if (TestNet()) - return INT_MAX; // never + return AUXPOW_START_TESTNET; else - return INT_MAX; // never + return AUXPOW_START_MAINNET; } bool CBlockHeader::CheckProofOfWork(int nHeight) const @@ -2369,7 +2369,7 @@ bool CBlockHeader::CheckProofOfWork(int nHeight) const // - this block must have our chain ID // - parent block must not have the same chain ID (see CAuxPow::Check) // - index of this chain in chain merkle tree must be pre-determined (see CAuxPow::Check) - if (!TestNet() && nHeight != INT_MAX && GetChainID() != GetOurChainID()) + if (!TestNet() && nHeight != INT_MAX && GetChainID() != AUXPOW_CHAIN_ID) return error("CheckProofOfWork() : block does not have our chain ID"); if (auxpow.get() != NULL)