X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=blobdiff_plain;f=src%2Fmain.cpp;h=e5668f98e5353d24c4b7020e58a75ab5d24f8cd6;hp=10aa8fdc3a479870a0ecadc75a5bb6aa1ff773ed;hb=77a43545b4491b9703d803765da9059d2bdd5aaa;hpb=f138f8e25f7282834f368b46ebb4072615441c2c diff --git a/src/main.cpp b/src/main.cpp index 10aa8fd..e5668f9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -57,7 +57,7 @@ uint256 nBestInvalidTrust = 0; uint256 hashBestChain = 0; CBlockIndex* pindexBest = NULL; -int64 nTimeBestReceived = 0; +int64_t nTimeBestReceived = 0; int nScriptCheckThreads = 0; CMedianFilter cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have @@ -76,8 +76,8 @@ CScript COINBASE_FLAGS; const string strMessageMagic = "NovaCoin Signed Message:\n"; // Settings -int64 nTransactionFee = MIN_TX_FEE; -int64 nMinimumInputValue = MIN_TX_FEE; +int64_t nTransactionFee = MIN_TX_FEE; +int64_t nMinimumInputValue = MIN_TX_FEE; extern enum Checkpoints::CPMode CheckpointsMode; @@ -491,7 +491,7 @@ bool CTransaction::CheckTransaction() const return DoS(100, error("CTransaction::CheckTransaction() : size limits failed")); // Check for negative or overflow output values - int64 nValueOut = 0; + int64_t nValueOut = 0; for (unsigned int i = 0; i < vout.size(); i++) { const CTxOut& txout = vout[i]; @@ -531,13 +531,13 @@ bool CTransaction::CheckTransaction() const return true; } -int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, enum GetMinFee_mode mode, unsigned int nBytes) const +int64_t CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, enum GetMinFee_mode mode, unsigned int nBytes) const { // Use new fees approach if we are on test network or // switch date has been reached bool fNewApproach = fTestNet || nTime > FEE_SWITCH_TIME; - int64 nMinTxFee = MIN_TX_FEE, nMinRelayTxFee = MIN_RELAY_TX_FEE; + int64_t nMinTxFee = MIN_TX_FEE, nMinRelayTxFee = MIN_RELAY_TX_FEE; if(!fNewApproach || IsCoinStake()) { @@ -547,10 +547,10 @@ int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, enum Get } // Base fee is either nMinTxFee or nMinRelayTxFee - int64 nBaseFee = (mode == GMF_RELAY) ? nMinRelayTxFee : nMinTxFee; + int64_t nBaseFee = (mode == GMF_RELAY) ? nMinRelayTxFee : nMinTxFee; unsigned int nNewBlockSize = nBlockSize + nBytes; - int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee; + int64_t nMinFee = (1 + (int64_t)nBytes / 1000) * nBaseFee; if (fNewApproach) { @@ -621,7 +621,7 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs, return tx.DoS(100, error("CTxMemPool::accept() : coinstake as individual tx")); // To help v0.1.5 clients who would see it as a negative number - if ((int64)tx.nLockTime > std::numeric_limits::max()) + if ((int64_t)tx.nLockTime > std::numeric_limits::max()) return error("CTxMemPool::accept() : not accepting nLockTime beyond 2038 yet"); // Rather not work on nonstandard transactions (unless -testnet) @@ -689,13 +689,13 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs, // you should add code here to check that the transaction does a // reasonable number of ECDSA signature verifications. - int64 nFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); + int64_t nFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); unsigned int nSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); // Don't accept it if it can't get into a block - int64 txMinFee = tx.GetMinFee(1000, true, GMF_RELAY, nSize); + int64_t txMinFee = tx.GetMinFee(1000, true, GMF_RELAY, nSize); if (nFees < txMinFee) - return error("CTxMemPool::accept() : not enough fees %s, %" PRI64d " < %" PRI64d, + return error("CTxMemPool::accept() : not enough fees %s, %" PRId64 " < %" PRId64, hash.ToString().c_str(), nFees, txMinFee); @@ -706,8 +706,8 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs, { static CCriticalSection cs; static double dFreeCount; - static int64 nLastTime; - int64 nNow = GetTime(); + static int64_t nLastTime; + int64_t nNow = GetTime(); { LOCK(cs); @@ -1012,7 +1012,7 @@ CBigNum inline GetProofOfStakeLimit(int nHeight, unsigned int nTime) } // miner's coin base reward based on nBits -int64 GetProofOfWorkReward(unsigned int nBits, int64 nFees) +int64_t GetProofOfWorkReward(unsigned int nBits, int64_t nFees) { CBigNum bnSubsidyLimit = MAX_MINT_PROOF_OF_WORK; @@ -1034,26 +1034,26 @@ int64 GetProofOfWorkReward(unsigned int nBits, int64 nFees) { CBigNum bnMidValue = (bnLowerBound + bnUpperBound) / 2; if (fDebug && GetBoolArg("-printcreation")) - printf("GetProofOfWorkReward() : lower=%" PRI64d " upper=%" PRI64d " mid=%" PRI64d "\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64()); + printf("GetProofOfWorkReward() : lower=%" PRId64 " upper=%" PRId64 " mid=%" PRId64 "\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64()); if (bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnMidValue * bnTargetLimit > bnSubsidyLimit * bnSubsidyLimit * bnSubsidyLimit * bnSubsidyLimit * bnSubsidyLimit * bnSubsidyLimit * bnTarget) bnUpperBound = bnMidValue; else bnLowerBound = bnMidValue; } - int64 nSubsidy = bnUpperBound.getuint64(); + int64_t nSubsidy = bnUpperBound.getuint64(); nSubsidy = (nSubsidy / CENT) * CENT; if (fDebug && GetBoolArg("-printcreation")) - printf("GetProofOfWorkReward() : create=%s nBits=0x%08x nSubsidy=%" PRI64d "\n", FormatMoney(nSubsidy).c_str(), nBits, nSubsidy); + printf("GetProofOfWorkReward() : create=%s nBits=0x%08x nSubsidy=%" PRId64 "\n", FormatMoney(nSubsidy).c_str(), nBits, nSubsidy); return min(nSubsidy, MAX_MINT_PROOF_OF_WORK) + nFees; } // miner's coin stake reward based on nBits and coin age spent (coin-days) -int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly) +int64_t GetProofOfStakeReward(int64_t nCoinAge, unsigned int nBits, unsigned int nTime, bool bCoinYearOnly) { - int64 nRewardCoinYear, nSubsidy, nSubsidyLimit = 10 * COIN; + int64_t nRewardCoinYear, nSubsidy, nSubsidyLimit = 10 * COIN; if(fTestNet || nTime > STAKE_SWITCH_TIME) { @@ -1075,7 +1075,7 @@ int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTi { CBigNum bnMidValue = (bnLowerBound + bnUpperBound) / 2; if (fDebug && GetBoolArg("-printcreation")) - printf("GetProofOfStakeReward() : lower=%" PRI64d " upper=%" PRI64d " mid=%" PRI64d "\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64()); + printf("GetProofOfStakeReward() : lower=%" PRId64 " upper=%" PRId64 " mid=%" PRId64 "\n", bnLowerBound.getuint64(), bnUpperBound.getuint64(), bnMidValue.getuint64()); if(!fTestNet && nTime < STAKECURVE_SWITCH_TIME) { @@ -1136,14 +1136,14 @@ int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTi } if (fDebug && GetBoolArg("-printcreation")) - printf("GetProofOfStakeReward(): create=%s nCoinAge=%" PRI64d " nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits); + printf("GetProofOfStakeReward(): create=%s nCoinAge=%" PRId64 " nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits); return nSubsidy; } -static const int64 nTargetTimespan = 7 * 24 * 60 * 60; // one week +static const int64_t nTargetTimespan = 7 * 24 * 60 * 60; // one week // get proof of work blocks max spacing according to hard-coded conditions -int64 inline GetTargetSpacingWorkMax(int nHeight, unsigned int nTime) +int64_t inline GetTargetSpacingWorkMax(int nHeight, unsigned int nTime) { if(nTime > TARGETS_SWITCH_TIME) return 3 * nStakeTargetSpacing; // 30 minutes on mainNet since 20 Jul 2013 00:00:00 @@ -1157,7 +1157,7 @@ int64 inline GetTargetSpacingWorkMax(int nHeight, unsigned int nTime) // // maximum nBits value could possible be required nTime after // -unsigned int ComputeMaxBits(CBigNum bnTargetLimit, unsigned int nBase, int64 nTime) +unsigned int ComputeMaxBits(CBigNum bnTargetLimit, unsigned int nBase, int64_t nTime) { CBigNum bnResult; bnResult.SetCompact(nBase); @@ -1177,7 +1177,7 @@ unsigned int ComputeMaxBits(CBigNum bnTargetLimit, unsigned int nBase, int64 nTi // minimum amount of work that could possibly be required nTime after // minimum proof-of-work required was nBase // -unsigned int ComputeMinWork(unsigned int nBase, int64 nTime) +unsigned int ComputeMinWork(unsigned int nBase, int64_t nTime) { return ComputeMaxBits(bnProofOfWorkLimit, nBase, nTime); } @@ -1186,7 +1186,7 @@ unsigned int ComputeMinWork(unsigned int nBase, int64 nTime) // minimum amount of stake that could possibly be required nTime after // minimum proof-of-stake required was nBase // -unsigned int ComputeMinStake(unsigned int nBase, int64 nTime, unsigned int nBlockTime) +unsigned int ComputeMinStake(unsigned int nBase, int64_t nTime, unsigned int nBlockTime) { return ComputeMaxBits(GetProofOfStakeLimit(0, nBlockTime), nBase, nTime); } @@ -1214,14 +1214,14 @@ unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfS if (pindexPrevPrev->pprev == NULL) return bnTargetLimit.GetCompact(); // second block - int64 nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime(); + int64_t nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime(); // ppcoin: target change every block // ppcoin: retarget with exponential moving toward target spacing CBigNum bnNew; bnNew.SetCompact(pindexPrev->nBits); - int64 nTargetSpacing = fProofOfStake? nStakeTargetSpacing : min(GetTargetSpacingWorkMax(pindexLast->nHeight, pindexLast->nTime), (int64) nStakeTargetSpacing * (1 + pindexLast->nHeight - pindexPrev->nHeight)); - int64 nInterval = nTargetTimespan / nTargetSpacing; + int64_t nTargetSpacing = fProofOfStake? nStakeTargetSpacing : min(GetTargetSpacingWorkMax(pindexLast->nHeight, pindexLast->nTime), (int64_t) nStakeTargetSpacing * (1 + pindexLast->nHeight - pindexPrev->nHeight)); + int64_t nInterval = nTargetTimespan / nTargetSpacing; bnNew *= ((nInterval - 1) * nTargetSpacing + nActualSpacing + nActualSpacing); bnNew /= ((nInterval + 1) * nTargetSpacing); @@ -1257,7 +1257,7 @@ bool IsInitialBlockDownload() { if (pindexBest == NULL || nBestHeight < Checkpoints::GetTotalBlocksEstimate()) return true; - static int64 nLastUpdate; + static int64_t nLastUpdate; static CBlockIndex* pindexLastBest; if (pindexBest != pindexLastBest) { @@ -1280,11 +1280,11 @@ void static InvalidChainFound(CBlockIndex* pindexNew) uint256 nBestInvalidBlockTrust = pindexNew->nChainTrust - pindexNew->pprev->nChainTrust; uint256 nBestBlockTrust = pindexBest->nHeight != 0 ? (pindexBest->nChainTrust - pindexBest->pprev->nChainTrust) : pindexBest->nChainTrust; - printf("InvalidChainFound: invalid block=%s height=%d trust=%s blocktrust=%" PRI64d " date=%s\n", + printf("InvalidChainFound: invalid block=%s height=%d trust=%s blocktrust=%" PRId64 " date=%s\n", pindexNew->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->nHeight, CBigNum(pindexNew->nChainTrust).ToString().c_str(), nBestInvalidBlockTrust.Get64(), DateTimeStrFormat("%x %H:%M:%S", pindexNew->GetBlockTime()).c_str()); - printf("InvalidChainFound: current best=%s height=%d trust=%s blocktrust=%" PRI64d " date=%s\n", + printf("InvalidChainFound: current best=%s height=%d trust=%s blocktrust=%" PRId64 " date=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, CBigNum(pindexBest->nChainTrust).ToString().c_str(), nBestBlockTrust.Get64(), @@ -1431,12 +1431,12 @@ const CTxOut& CTransaction::GetOutputFor(const CTxIn& input, const MapPrevTx& in return txPrev.vout[input.prevout.n]; } -int64 CTransaction::GetValueIn(const MapPrevTx& inputs) const +int64_t CTransaction::GetValueIn(const MapPrevTx& inputs) const { if (IsCoinBase()) return 0; - int64 nResult = 0; + int64_t nResult = 0; for (unsigned int i = 0; i < vin.size(); i++) { nResult += GetOutputFor(vin[i], inputs).nValue; @@ -1482,8 +1482,8 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs, map VALIDATION_SWITCH_TIME || fTestNet) ? GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) : 0; - int64 nReward = GetValueOut() - nValueIn; - int64 nCalculatedReward = GetProofOfStakeReward(nCoinAge, pindexBlock->nBits, nTime) - GetMinFee(1, false, GMF_BLOCK, nTxSize) + CENT; + int64_t nReward = GetValueOut() - nValueIn; + int64_t nCalculatedReward = GetProofOfStakeReward(nCoinAge, pindexBlock->nBits, nTime) - GetMinFee(1, false, GMF_BLOCK, nTxSize) + CENT; if (nReward > nCalculatedReward) - return DoS(100, error("ConnectInputs() : coinstake pays too much(actual=%" PRI64d " vs calculated=%" PRI64d ")", nReward, nCalculatedReward)); + return DoS(100, error("ConnectInputs() : coinstake pays too much(actual=%" PRId64 " vs calculated=%" PRId64 ")", nReward, nCalculatedReward)); } else { @@ -1586,7 +1586,7 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs, map mapQueuedChanges; CCheckQueueControl control(fScriptChecks && nScriptCheckThreads ? &scriptcheckqueue : NULL); - int64 nFees = 0; - int64 nValueIn = 0; - int64 nValueOut = 0; + int64_t nFees = 0; + int64_t nValueIn = 0; + int64_t nValueOut = 0; unsigned int nSigOps = 0; BOOST_FOREACH(CTransaction& tx, vtx) { @@ -1760,8 +1760,8 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) if (nSigOps > MAX_BLOCK_SIGOPS) return DoS(100, error("ConnectBlock() : too many sigops")); - int64 nTxValueIn = tx.GetValueIn(mapInputs); - int64 nTxValueOut = tx.GetValueOut(); + int64_t nTxValueIn = tx.GetValueIn(mapInputs); + int64_t nTxValueOut = tx.GetValueOut(); nValueIn += nTxValueIn; nValueOut += nTxValueOut; if (!tx.IsCoinStake()) @@ -1781,11 +1781,11 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) if (IsProofOfWork()) { - int64 nBlockReward = GetProofOfWorkReward(nBits, nFees); + int64_t nBlockReward = GetProofOfWorkReward(nBits, nFees); // Check coinbase reward if (vtx[0].GetValueOut() > nBlockReward) - return error("CheckBlock() : coinbase reward exceeded (actual=%" PRI64d " vs calculated=%" PRI64d ")", + return error("CheckBlock() : coinbase reward exceeded (actual=%" PRId64 " vs calculated=%" PRId64 ")", vtx[0].GetValueOut(), nBlockReward); } @@ -1799,7 +1799,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) // fees are not collected by proof-of-stake miners // fees are destroyed to compensate the entire network if (fDebug && IsProofOfStake() && GetBoolArg("-printcreation")) - printf("ConnectBlock() : destroy=%s nFees=%" PRI64d "\n", FormatMoney(nFees).c_str(), nFees); + printf("ConnectBlock() : destroy=%s nFees=%" PRId64 "\n", FormatMoney(nFees).c_str(), nFees); if (fJustCheck) return true; @@ -2035,7 +2035,7 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) uint256 nBestBlockTrust = pindexBest->nHeight != 0 ? (pindexBest->nChainTrust - pindexBest->pprev->nChainTrust) : pindexBest->nChainTrust; - printf("SetBestChain: new best=%s height=%d trust=%s blocktrust=%" PRI64d " date=%s\n", + printf("SetBestChain: new best=%s height=%d trust=%s blocktrust=%" PRId64 " date=%s\n", hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, CBigNum(nBestChainTrust).ToString().c_str(), nBestBlockTrust.Get64(), @@ -2077,7 +2077,7 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) // guaranteed to be in main chain by sync-checkpoint. This rule is // introduced to help nodes establish a consistent view of the coin // age (trust score) of competing branches. -bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const +bool CTransaction::GetCoinAge(CTxDB& txdb, uint64_t& nCoinAge) const { CBigNum bnCentSecond = 0; // coin age in the unit of cent-seconds nCoinAge = 0; @@ -2102,11 +2102,11 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const if (block.GetBlockTime() + nStakeMinAge > nTime) continue; // only count coins meeting min age requirement - int64 nValueIn = txPrev.vout[txin.prevout.n].nValue; + int64_t nValueIn = txPrev.vout[txin.prevout.n].nValue; bnCentSecond += CBigNum(nValueIn) * (nTime-txPrev.nTime) / CENT; if (fDebug && GetBoolArg("-printcoinage")) - printf("coin age nValueIn=%" PRI64d " nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString().c_str()); + printf("coin age nValueIn=%" PRId64 " nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString().c_str()); } CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60); @@ -2117,14 +2117,14 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const } // ppcoin: total coin age spent in block, in the unit of coin-days. -bool CBlock::GetCoinAge(uint64& nCoinAge) const +bool CBlock::GetCoinAge(uint64_t& nCoinAge) const { nCoinAge = 0; CTxDB txdb("r"); BOOST_FOREACH(const CTransaction& tx, vtx) { - uint64 nTxCoinAge; + uint64_t nTxCoinAge; if (tx.GetCoinAge(txdb, nTxCoinAge)) nCoinAge += nTxCoinAge; else @@ -2134,7 +2134,7 @@ bool CBlock::GetCoinAge(uint64& nCoinAge) const if (nCoinAge == 0) // block coin age minimum 1 coin-day nCoinAge = 1; if (fDebug && GetBoolArg("-printcoinage")) - printf("block coin age total nCoinDays=%" PRI64d "\n", nCoinAge); + printf("block coin age total nCoinDays=%" PRId64 "\n", nCoinAge); return true; } @@ -2173,14 +2173,14 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos) } // ppcoin: compute stake modifier - uint64 nStakeModifier = 0; + uint64_t nStakeModifier = 0; bool fGeneratedStakeModifier = false; if (!ComputeNextStakeModifier(pindexNew, nStakeModifier, fGeneratedStakeModifier)) return error("AddToBlockIndex() : ComputeNextStakeModifier() failed"); pindexNew->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier); pindexNew->nStakeModifierChecksum = GetStakeModifierChecksum(pindexNew); if (!CheckStakeModifierCheckpoints(pindexNew->nHeight, pindexNew->nStakeModifierChecksum)) - return error("AddToBlockIndex() : Rejected by stake modifier checkpoint height=%d, modifier=0x%016" PRI64x, pindexNew->nHeight, nStakeModifier); + return error("AddToBlockIndex() : Rejected by stake modifier checkpoint height=%d, modifier=0x%016" PRIx64, pindexNew->nHeight, nStakeModifier); // Add to mapBlockIndex map::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; @@ -2238,7 +2238,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c return DoS(100, error("CheckBlock() : first tx is not coinbase")); // Check coinbase timestamp - if (GetBlockTime() < PastDrift((int64)vtx[0].nTime)) + if (GetBlockTime() < PastDrift((int64_t)vtx[0].nTime)) return DoS(50, error("CheckBlock() : coinbase timestamp is too late")); for (unsigned int i = 1; i < vtx.size(); i++) @@ -2247,7 +2247,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c return DoS(100, error("CheckBlock() : more than one coinbase")); // Check transaction timestamp - if (GetBlockTime() < (int64)vtx[i].nTime) + if (GetBlockTime() < (int64_t)vtx[i].nTime) return DoS(50, error("CheckBlock() : block timestamp earlier than transaction timestamp")); } @@ -2268,8 +2268,8 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c return DoS(100, error("CheckBlock() : more than one coinstake")); // Check coinstake timestamp - if (GetBlockTime() != (int64)vtx[1].nTime) - return DoS(50, error("CheckBlock() : coinstake timestamp violation nTimeBlock=%" PRI64d " nTimeTx=%u", GetBlockTime(), vtx[1].nTime)); + if (GetBlockTime() != (int64_t)vtx[1].nTime) + return DoS(50, error("CheckBlock() : coinstake timestamp violation nTimeBlock=%" PRId64 " nTimeTx=%u", GetBlockTime(), vtx[1].nTime)); // NovaCoin: check proof-of-stake block signature if (fCheckSig && !CheckBlockSignature(true)) @@ -2530,7 +2530,7 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) if (pcheckpoint && pblock->hashPrevBlock != hashBestChain && !Checkpoints::WantedByPendingSyncCheckpoint(hash)) { // Extra checks to prevent "fill up memory by spamming with bogus blocks" - int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime; + int64_t deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime; CBigNum bnNewBlock; bnNewBlock.SetCompact(pblock->nBits); CBigNum bnRequired; @@ -2628,11 +2628,11 @@ bool CBlock::SignBlock(CWallet& wallet) if (IsProofOfStake()) return true; - static int64 nLastCoinStakeSearchTime = GetAdjustedTime(); // startup timestamp + static int64_t nLastCoinStakeSearchTime = GetAdjustedTime(); // startup timestamp CKey key; CTransaction txCoinStake; - int64 nSearchTime = txCoinStake.nTime; // search to current time + int64_t nSearchTime = txCoinStake.nTime; // search to current time if (nSearchTime > nLastCoinStakeSearchTime) { @@ -2719,9 +2719,9 @@ bool CBlock::CheckBlockSignature(bool fProofOfStake) const return false; } -bool CheckDiskSpace(uint64 nAdditionalBytes) +bool CheckDiskSpace(uint64_t nAdditionalBytes) { - uint64 nFreeBytesAvailable = filesystem::space(GetDataDir()).available; + uint64_t nFreeBytesAvailable = filesystem::space(GetDataDir()).available; // Check for nMinDiskSpace bytes (currently 50MB) if (nFreeBytesAvailable < nMinDiskSpace + nAdditionalBytes) @@ -2992,7 +2992,7 @@ void PrintBlockTree() bool LoadExternalBlockFile(FILE* fileIn) { - int64 nStart = GetTimeMillis(); + int64_t nStart = GetTimeMillis(); int nLoaded = 0; { @@ -3046,7 +3046,7 @@ bool LoadExternalBlockFile(FILE* fileIn) BOOST_CURRENT_FUNCTION); } } - printf("Loaded %i blocks from external file in %" PRI64d "ms\n", nLoaded, GetTimeMillis() - nStart); + printf("Loaded %i blocks from external file in %" PRId64 "ms\n", nLoaded, GetTimeMillis() - nStart); return nLoaded > 0; } @@ -3179,10 +3179,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) return false; } - int64 nTime; + int64_t nTime; CAddress addrMe; CAddress addrFrom; - uint64 nNonce = 1; + uint64_t nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; if (pfrom->nVersion < MIN_PROTO_VERSION) { @@ -3332,8 +3332,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // Store the new addresses vector vAddrOk; - int64 nNow = GetAdjustedTime(); - int64 nSince = nNow - 10 * 60; + int64_t nNow = GetAdjustedTime(); + int64_t nSince = nNow - 10 * 60; BOOST_FOREACH(CAddress& addr, vAddr) { if (fShutdown) @@ -3352,7 +3352,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) static uint256 hashSalt; if (hashSalt == 0) hashSalt = GetRandHash(); - uint64 hashAddr = addr.GetHash(); + uint64_t hashAddr = addr.GetHash(); uint256 hashRand = hashSalt ^ (hashAddr<<32) ^ ((GetTime()+hashAddr)/(24*60*60)); hashRand = Hash(BEGIN(hashRand), END(hashRand)); multimap mapMix; @@ -3680,7 +3680,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) else if (strCommand == "getaddr") { // Don't return addresses older than nCutOff timestamp - int64 nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60); + int64_t nCutOff = GetTime() - (nNodeLifespan * 24 * 60 * 60); pfrom->vAddrToSend.clear(); vector vAddr = addrman.GetAddr(); BOOST_FOREACH(const CAddress &addr, vAddr) @@ -3756,7 +3756,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) { if (pfrom->nVersion > BIP0031_VERSION) { - uint64 nonce = 0; + uint64_t nonce = 0; vRecv >> nonce; // Echo the message back with the nonce. This allows for two useful features: // @@ -3953,7 +3953,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Keep-alive ping. We send a nonce of zero because we don't use it anywhere // right now. if (pto->nLastSend && GetTime() - pto->nLastSend > 30 * 60 && pto->vSend.empty()) { - uint64 nonce = 0; + uint64_t nonce = 0; if (pto->nVersion > BIP0031_VERSION) pto->PushMessage("ping", nonce); else @@ -3970,7 +3970,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) ResendWalletTransactions(); // Address refresh broadcast - static int64 nLastRebroadcast; + static int64_t nLastRebroadcast; if (!IsInitialBlockDownload() && (GetTime() - nLastRebroadcast > 24 * 60 * 60)) { { @@ -4082,7 +4082,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle) // Message: getdata // vector vGetData; - int64 nNow = GetTime() * 1000000; + int64_t nNow = GetTime() * 1000000; CTxDB txdb("r"); while (!pto->mapAskFor.empty() && (*pto->mapAskFor.begin()).first <= nNow) {