diff options
-rw-r--r-- | src/chainparams.cpp | 4 | ||||
-rw-r--r-- | src/chainparams.h | 3 | ||||
-rw-r--r-- | src/consensus/params.h | 3 | ||||
-rw-r--r-- | src/pow.cpp | 9 | ||||
-rw-r--r-- | src/rpcmining.cpp | 23 | ||||
-rw-r--r-- | src/wallet/db.h | 3 | ||||
-rw-r--r-- | src/wallet/walletdb.h | 1 |
7 files changed, 24 insertions, 22 deletions
diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 8633d51b2f..97312b366d 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -105,7 +105,7 @@ public: consensus.nMajorityEnforceBlockUpgrade = 750; consensus.nMajorityRejectBlockOutdated = 950; consensus.nMajorityWindow = 1000; - consensus.powLimit = ~arith_uint256(0) >> 32; + consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks consensus.nPowTargetSpacing = 10 * 60; consensus.fPowAllowMinDifficultyBlocks = false; @@ -245,7 +245,7 @@ public: consensus.nMajorityEnforceBlockUpgrade = 750; consensus.nMajorityRejectBlockOutdated = 950; consensus.nMajorityWindow = 1000; - consensus.powLimit = ~arith_uint256(0) >> 1; + consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); pchMessageStart[0] = 0xfa; pchMessageStart[1] = 0xbf; pchMessageStart[2] = 0xb5; diff --git a/src/chainparams.h b/src/chainparams.h index d0613beb45..e5e691cc53 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -6,7 +6,6 @@ #ifndef BITCOIN_CHAINPARAMS_H #define BITCOIN_CHAINPARAMS_H -#include "arith_uint256.h" #include "chainparamsbase.h" #include "checkpoints.h" #include "consensus/params.h" @@ -45,7 +44,7 @@ public: const CMessageHeader::MessageStartChars& MessageStart() const { return pchMessageStart; } const std::vector<unsigned char>& AlertKey() const { return vAlertPubKey; } int GetDefaultPort() const { return nDefaultPort; } - const arith_uint256& ProofOfWorkLimit() const { return consensus.powLimit; } + const uint256& ProofOfWorkLimit() const { return consensus.powLimit; } int SubsidyHalvingInterval() const { return consensus.nSubsidyHalvingInterval; } int EnforceBlockUpgradeMajority() const { return consensus.nMajorityEnforceBlockUpgrade; } int RejectBlockOutdatedMajority() const { return consensus.nMajorityRejectBlockOutdated; } diff --git a/src/consensus/params.h b/src/consensus/params.h index c4cfa48c7e..35d447b712 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -6,7 +6,6 @@ #ifndef BITCOIN_CONSENSUS_CONSENSUS_PARAMS_H #define BITCOIN_CONSENSUS_CONSENSUS_PARAMS_H -#include "arith_uint256.h" #include "uint256.h" namespace Consensus { @@ -21,7 +20,7 @@ struct Params { int nMajorityRejectBlockOutdated; int nMajorityWindow; /** Proof of work parameters */ - arith_uint256 powLimit; + uint256 powLimit; bool fPowAllowMinDifficultyBlocks; int64_t nPowTargetSpacing; int64_t nPowTargetTimespan; diff --git a/src/pow.cpp b/src/pow.cpp index cf7ac387f2..fc6ed4f3d1 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -13,7 +13,7 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { - unsigned int nProofOfWorkLimit = params.powLimit.GetCompact(); + unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); // Genesis block if (pindexLast == NULL) @@ -61,6 +61,7 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF nActualTimespan = params.nPowTargetTimespan*4; // Retarget + const arith_uint256 bnPowLimit = UintToArith256(params.powLimit); arith_uint256 bnNew; arith_uint256 bnOld; bnNew.SetCompact(pindexLast->nBits); @@ -68,8 +69,8 @@ unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nF bnNew *= nActualTimespan; bnNew /= params.nPowTargetTimespan; - if (bnNew > params.powLimit) - bnNew = params.powLimit; + if (bnNew > bnPowLimit) + bnNew = bnPowLimit; /// debug print LogPrintf("GetNextWorkRequired RETARGET\n"); @@ -89,7 +90,7 @@ bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& bnTarget.SetCompact(nBits, &fNegative, &fOverflow); // Check range - if (fNegative || bnTarget == 0 || fOverflow || bnTarget > params.powLimit) + if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) return error("CheckProofOfWork(): nBits below minimum work"); // Check proof of work matches claimed amount diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 1e6531f68a..949fe3ed52 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -629,14 +629,19 @@ Value submitblock(const Array& params, bool fHelp) throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed"); uint256 hash = block.GetHash(); - BlockMap::iterator mi = mapBlockIndex.find(hash); - if (mi != mapBlockIndex.end()) { - CBlockIndex *pindex = mi->second; - if (pindex->IsValid(BLOCK_VALID_SCRIPTS)) - return "duplicate"; - if (pindex->nStatus & BLOCK_FAILED_MASK) - return "duplicate-invalid"; - // Otherwise, we might only have the header - process the block before returning + bool fBlockPresent = false; + { + LOCK(cs_main); + BlockMap::iterator mi = mapBlockIndex.find(hash); + if (mi != mapBlockIndex.end()) { + CBlockIndex *pindex = mi->second; + if (pindex->IsValid(BLOCK_VALID_SCRIPTS)) + return "duplicate"; + if (pindex->nStatus & BLOCK_FAILED_MASK) + return "duplicate-invalid"; + // Otherwise, we might only have the header - process the block before returning + fBlockPresent = true; + } } CValidationState state; @@ -644,7 +649,7 @@ Value submitblock(const Array& params, bool fHelp) RegisterValidationInterface(&sc); bool fAccepted = ProcessNewBlock(state, NULL, &block); UnregisterValidationInterface(&sc); - if (mi != mapBlockIndex.end()) + if (fBlockPresent) { if (fAccepted && !sc.found) return "duplicate-inconclusive"; diff --git a/src/wallet/db.h b/src/wallet/db.h index 0c2c139d89..790ae50413 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -25,9 +25,6 @@ class COutPoint; extern unsigned int nWalletDBUpdated; -void ThreadFlushWalletDB(const std::string& strWalletFile); - - class CDBEnv { private: diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h index a1c38b9d3d..e5f64ffaae 100644 --- a/src/wallet/walletdb.h +++ b/src/wallet/walletdb.h @@ -138,5 +138,6 @@ private: }; bool BackupWallet(const CWallet& wallet, const std::string& strDest); +void ThreadFlushWalletDB(const std::string& strFile); #endif // BITCOIN_WALLETDB_H |