From 20869186fe726b616384ea18f61dbdc70ed7b66d Mon Sep 17 00:00:00 2001 From: MrNice Date: Fri, 5 Jan 2018 07:08:24 +0000 Subject: [PATCH] compiler fixes --- src/alert.cpp | 4 +- src/db.cpp | 2 +- src/init.cpp | 16 +++---- src/kernel.cpp | 26 ++++++------ src/magirpc.cpp | 10 +++-- src/main.cpp | 98 +++++++++++++++++++++---------------------- src/main.h | 6 +-- src/net.cpp | 4 +- src/net.h | 2 +- src/rpcblockchain.cpp | 2 +- src/rpcmining.cpp | 2 +- src/rpcnet.cpp | 2 +- src/rpcwallet.cpp | 2 +- src/txdb.cpp | 2 +- src/util.cpp | 8 ++-- src/util.h | 2 +- src/wallet.cpp | 53 ++++++++++++++--------- src/walletdb.cpp | 8 ++-- 18 files changed, 133 insertions(+), 116 deletions(-) diff --git a/src/alert.cpp b/src/alert.cpp index a79e9081c3..fffc040bc6 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -52,8 +52,8 @@ std::string CUnsignedAlert::ToString() const return strprintf( "CAlert(\n" " nVersion = %d\n" - " nRelayUntil = %"PRI64d"\n" - " nExpiration = %"PRI64d"\n" + " nRelayUntil = %" PRI64d "\n" + " nExpiration = %" PRI64d "\n" " nID = %d\n" " nCancel = %d\n" " setCancel = %s\n" diff --git a/src/db.cpp b/src/db.cpp index 93c4573fa0..df7198ac7a 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -462,7 +462,7 @@ void CDBEnv::Flush(bool fShutdown) else mi++; } - printf("DBFlush(%s)%s ended %15"PRI64d"ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart); + printf("DBFlush(%s)%s ended %15" PRI64d "ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart); if (fShutdown) { char** listp; diff --git a/src/init.cpp b/src/init.cpp index c1c8e4964e..ab0a9cd610 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -706,7 +706,7 @@ bool AppInit2() printf("Shutdown requested. Exiting.\n"); return false; } - printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart); + printf(" block index %15" PRI64d "ms\n", GetTimeMillis() - nStart); if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree")) { @@ -798,7 +798,7 @@ bool AppInit2() } printf("%s", strErrors.str().c_str()); - printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart); + printf(" wallet %15" PRI64d "ms\n", GetTimeMillis() - nStart); RegisterWallet(pwalletMain); @@ -818,7 +818,7 @@ bool AppInit2() printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight); nStart = GetTimeMillis(); pwalletMain->ScanForWalletTransactions(pindexRescan, true); - printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart); + printf(" rescan %15" PRI64d "ms\n", GetTimeMillis() - nStart); } // ********************************************************* Step 9: import blocks @@ -859,7 +859,7 @@ bool AppInit2() printf("Invalid or missing peers.dat; recreating\n"); } - printf("Loaded %i addresses from peers.dat %"PRI64d"ms\n", + printf("Loaded %i addresses from peers.dat %" PRI64d "ms\n", addrman.size(), GetTimeMillis() - nStart); // ********************************************************* Step 11: start node @@ -870,11 +870,11 @@ bool AppInit2() RandAddSeedPerfmon(); //// debug print - printf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size()); + printf("mapBlockIndex.size() = %" PRIszu "\n", mapBlockIndex.size()); printf("nBestHeight = %d\n", nBestHeight); - printf("setKeyPool.size() = %"PRIszu"\n", pwalletMain->setKeyPool.size()); - printf("mapWallet.size() = %"PRIszu"\n", pwalletMain->mapWallet.size()); - printf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain->mapAddressBook.size()); + printf("setKeyPool.size() = %" PRIszu "\n", pwalletMain->setKeyPool.size()); + printf("mapWallet.size() = %" PRIszu "\n", pwalletMain->mapWallet.size()); + printf("mapAddressBook.size() = %" PRIszu "\n", pwalletMain->mapAddressBook.size()); if (!NewThread(StartNode, NULL)) InitError(_("Error: could not start node")); diff --git a/src/kernel.cpp b/src/kernel.cpp index 9b7ca1a68d..0350dd4fa5 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -134,7 +134,7 @@ int64 GetMagiWeight_TestNetV2(int64 nValueIn, int64 nIntervalBeginning, int64 nI double rMro = (double)(nValueIn*6)/(double)nnMoneySupply, rEpf = exp_n(1/wfa(rMro)/wfb(rMro)/wfc(rMro)); nWeight = 5.55243 * ( pow(rEpf, -0.3 * rStakeDays * 480. / 8.177) - pow(rEpf, -0.6 * rStakeDays * 480. / 8.177) ) * rStakeDays * 240.; - if (fDebugMagiPoS) printf("@GetMagiWeight_TestNetV2 = %"PRI64d"\n", max((int64)0, min((int64)(nWeight * 24 * 60 * 60/2), (int64)(nStakeMaxAge)))); + if (fDebugMagiPoS) printf("@GetMagiWeight_TestNetV2 = %" PRI64d "\n", max((int64)0, min((int64)(nWeight * 24 * 60 * 60/2), (int64)(nStakeMaxAge)))); return max((int64)0, min((int64)(nWeight * 24 * 60 * 60/2), (int64)(nStakeMaxAge))); } @@ -176,7 +176,7 @@ int64 GetMagiWeightV2(int64 nValueIn, int64 nIntervalBeginning, int64 nIntervalE nWeight = 42.2474 * ( pow(rEpf, -0.55 * (rStakeDays+2.) / 0.4719) - pow(rEpf, -0.6 * (rStakeDays+2.) / 0.4719) ) * rStakeDays; - if (fDebugMagiPoS) printf("@GetMagiWeightV2 = %"PRI64d"\n", max((int64)0, min((int64)(nWeight * 24 * 60 * 60), (int64)nStakeMaxAge))); + if (fDebugMagiPoS) printf("@GetMagiWeightV2 = %" PRI64d "\n", max((int64)0, min((int64)(nWeight * 24 * 60 * 60), (int64)nStakeMaxAge))); return max((int64)0, min((int64)(nWeight * 24 * 60 * 60), (int64)nStakeMaxAge)); } @@ -302,7 +302,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64& nStakeModif return error("ComputeNextStakeModifier: unable to get last modifier"); if (fDebug) { - printf("ComputeNextStakeModifier: prev modifier=0x%016"PRI64x" time=%s\n", nStakeModifier, DateTimeStrFormat(nModifierTime).c_str()); + printf("ComputeNextStakeModifier: prev modifier=0x%016" PRI64x " time=%s\n", nStakeModifier, DateTimeStrFormat(nModifierTime).c_str()); } if (nModifierTime / nModifierInterval >= pindexPrev->GetBlockTime() / nModifierInterval) return true; @@ -366,7 +366,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64& nStakeModif } if (fDebug) { - printf("ComputeNextStakeModifier: new modifier=0x%016"PRI64x" time=%s\n", nStakeModifierNew, DateTimeStrFormat(pindexPrev->GetBlockTime()).c_str()); + printf("ComputeNextStakeModifier: new modifier=0x%016" PRI64x " time=%s\n", nStakeModifierNew, DateTimeStrFormat(pindexPrev->GetBlockTime()).c_str()); } nStakeModifier = nStakeModifierNew; @@ -398,7 +398,7 @@ static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64& nStakeModifier else { if(fDebug) - printf(">> nStakeModifierTime = %"PRI64d", pindexFrom->GetBlockTime() = %"PRI64d", nStakeModifierSelectionInterval = %"PRI64d"\n", + printf(">> nStakeModifierTime = %" PRI64d ", pindexFrom->GetBlockTime() = %" PRI64d ", nStakeModifierSelectionInterval = %" PRI64d "\n", nStakeModifierTime, pindexFrom->GetBlockTime(), nStakeModifierSelectionInterval); return false; } @@ -452,7 +452,7 @@ bool CheckStakeKernelHash(CBlockIndex* pindexPrev, unsigned int nBits, const CBl bnTargetPerCoinDay.SetCompact(nBits); int64 nValueIn = txPrev.vout[prevout.n].nValue; - unsigned int nTimeTxPrev = txPrev.nTime; + //unsigned int nTimeTxPrev = txPrev.nTime; // v0.3 protocol kernel hash weight starts from 0 at the min age @@ -464,7 +464,7 @@ bool CheckStakeKernelHash(CBlockIndex* pindexPrev, unsigned int nBits, const CBl GetMagiWeight(nValueIn, txPrev.nTime, nTimeTx); CBigNum bnCoinDayWeight = CBigNum(nValueIn) * nTimeWeight / COIN / (24 * 60 * 60); - // printf(">>> CheckStakeKernelHash: nTimeWeight = %"PRI64d"\n", nTimeWeight); + // printf(">>> CheckStakeKernelHash: nTimeWeight = %" PRI64d "\n", nTimeWeight); // Calculate hash CDataStream ss(SER_GETHASH, 0); uint64 nStakeModifier = 0; @@ -485,12 +485,12 @@ bool CheckStakeKernelHash(CBlockIndex* pindexPrev, unsigned int nBits, const CBl hashProofOfStake = Hash(ss.begin(), ss.end()); if (fPrintProofOfStake) { - printf("CheckStakeKernelHash() : using modifier 0x%016"PRI64x" at height=%d timestamp=%s for block from height=%d timestamp=%s\n", + printf("CheckStakeKernelHash() : using modifier 0x%016" PRI64x " at height=%d timestamp=%s for block from height=%d timestamp=%s\n", nStakeModifier, nStakeModifierHeight, DateTimeStrFormat(nStakeModifierTime).c_str(), mapBlockIndex[blockFrom.GetHash()]->nHeight, DateTimeStrFormat(blockFrom.GetBlockTime()).c_str()); - printf("CheckStakeKernelHash() : check protocol=%s modifier=0x%016"PRI64x" nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", + printf("CheckStakeKernelHash() : check protocol=%s modifier=0x%016" PRI64x " nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", "0.3", nStakeModifier, nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx, @@ -504,7 +504,7 @@ bool CheckStakeKernelHash(CBlockIndex* pindexPrev, unsigned int nBits, const CBl { if(fDebug) { - printf(">>> nValueIn = %"PRI64d", nTimeWeight = %"PRI64d", nPrevMoneySupply = %"PRI64d"\n", nValueIn, nTimeWeight, pindexPrev->nMoneySupply); + printf(">>> nValueIn = %" PRI64d ", nTimeWeight = %" PRI64d ", nPrevMoneySupply = %" PRI64d "\n", nValueIn, nTimeWeight, pindexPrev->nMoneySupply); CBigNum hashTargett_ = bnCoinDayWeight * bnTargetPerCoinDay; printf(">>> bnCoinDayWeight = %s, bnTargetPerCoinDay = %s\n", bnCoinDayWeight.ToString().c_str(), bnTargetPerCoinDay.ToString().c_str()); @@ -522,12 +522,12 @@ bool CheckStakeKernelHash(CBlockIndex* pindexPrev, unsigned int nBits, const CBl if (fDebug && !fPrintProofOfStake) { - printf("CheckStakeKernelHash() : using modifier 0x%016"PRI64x" at height=%d timestamp=%s for block from height=%d timestamp=%s\n", + printf("CheckStakeKernelHash() : using modifier 0x%016" PRI64x " at height=%d timestamp=%s for block from height=%d timestamp=%s\n", nStakeModifier, nStakeModifierHeight, DateTimeStrFormat(nStakeModifierTime).c_str(), mapBlockIndex[blockFrom.GetHash()]->nHeight, DateTimeStrFormat(blockFrom.GetBlockTime()).c_str()); - printf("CheckStakeKernelHash() : pass protocol=%s modifier=0x%016"PRI64x" nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", + printf("CheckStakeKernelHash() : pass protocol=%s modifier=0x%016" PRI64x " nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", "0.3", nStakeModifier, nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx, @@ -535,7 +535,7 @@ bool CheckStakeKernelHash(CBlockIndex* pindexPrev, unsigned int nBits, const CBl } if(fDebug) { - printf(">>> nValueIn = %"PRI64d", nTimeWeight = %"PRI64d"\n", nValueIn, nTimeWeight); + printf(">>> nValueIn = %" PRI64d ", nTimeWeight = %" PRI64d "\n", nValueIn, nTimeWeight); CBigNum hashTargett_ = bnCoinDayWeight * bnTargetPerCoinDay; printf(">>> bnCoinDayWeight = %s, bnTargetPerCoinDay = %s\n", bnCoinDayWeight.ToString().c_str(), bnTargetPerCoinDay.ToString().c_str()); diff --git a/src/magirpc.cpp b/src/magirpc.cpp index 380865b5fb..422561000a 100644 --- a/src/magirpc.cpp +++ b/src/magirpc.cpp @@ -370,7 +370,7 @@ static string HTTPReply(int nStatus, const string& strMsg, bool keepalive) "HTTP/1.1 %d %s\r\n" "Date: %s\r\n" "Connection: %s\r\n" - "Content-Length: %"PRIszu"\r\n" + "Content-Length: %" PRIszu "\r\n" "Content-Type: application/json\r\n" "Server: Magi-json-rpc/%s\r\n" "\r\n" @@ -522,17 +522,19 @@ bool ClientAllowed(const boost::asio::ip::address& address) // Make sure that IPv4-compatible and IPv4-mapped IPv6 addresses are treated as IPv4 addresses if (address.is_v6() && (address.to_v6().is_v4_compatible() - || address.to_v6().is_v4_mapped())) + || address.to_v6().is_v4_mapped())){ return ClientAllowed(address.to_v6().to_v4()); + } - std::string ipv4addr = address.to_string(); + std::string ipv4addr = address.to_string(); if (address == asio::ip::address_v4::loopback() || address == asio::ip::address_v6::loopback() || (address.is_v4() // Check whether IPv4 addresses match 127.0.0.0/8 (loopback subnet) - && (address.to_v4().to_ulong() & 0xff000000) == 0x7f000000)) + && (address.to_v4().to_ulong() & 0xff000000) == 0x7f000000)){ return true; + } const string strAddress = address.to_string(); const vector& vAllow = mapMultiArgs["-rpcallowip"]; diff --git a/src/main.cpp b/src/main.cpp index c9b6efd3c7..3a34203ab6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -221,7 +221,7 @@ bool AddOrphanTx(const CDataStream& vMsg) // at most 500 megabytes of orphans: if (pvMsg->size() > 5000) { - printf("ignoring large orphan tx (size: %"PRIszu", hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str()); + printf("ignoring large orphan tx (size: %" PRIszu ", hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str()); delete pvMsg; return false; } @@ -230,7 +230,7 @@ bool AddOrphanTx(const CDataStream& vMsg) BOOST_FOREACH(const CTxIn& txin, tx.vin) mapOrphanTransactionsByPrev[txin.prevout.hash].insert(make_pair(hash, pvMsg)); - printf("stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString().substr(0,10).c_str(), + printf("stored orphan tx %s (mapsz %" PRIszu ")\n", hash.ToString().substr(0,10).c_str(), mapOrphanTransactions.size()); return true; } @@ -640,7 +640,7 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs, // Don't accept it if it can't get into a block int64 txMinFee = tx.GetMinFee(1000, false, GMF_RELAY, nSize); if (nFees < txMinFee) - return error("CTxMemPool::accept() : not enough fees %s, %"PRI64d" < %"PRI64d, + return error("CTxMemPool::accept() : not enough fees %s, %" PRI64d " < %" PRI64d, hash.ToString().c_str(), nFees, txMinFee); @@ -693,7 +693,7 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs, if (ptxOld) EraseFromWallets(ptxOld->GetHash()); - printf("CTxMemPool::accept() : accepted %s (poolsz %"PRIszu")\n", + printf("CTxMemPool::accept() : accepted %s (poolsz %" PRIszu ")\n", hash.ToString().substr(0,10).c_str(), mapTx.size()); return true; @@ -1156,7 +1156,7 @@ int64 GetProofOfWorkReward(int nBits, int nHeight, int64 nFees) return nSubsidy + nFees; } nSubsidy = (100 * COIN) >> (nHeight / 1051200); // cut in half every 1.05 mil blocks ~2 years - if (fDebugMagi) printf("@@GPoWR-testnet nHeight = %d, nSubsidy = %"PRI64d", nDiff = %f\n", + if (fDebugMagi) printf("@@GPoWR-testnet nHeight = %d, nSubsidy = %" PRI64d ", nDiff = %f\n", nHeight, nSubsidy/COIN, nDiff); return nSubsidy + nFees; } @@ -1188,7 +1188,7 @@ int64 GetProofOfWorkReward(int nBits, int nHeight, int64 nFees) nSubsidy = 495.05 * pow( (5.55243*(exp_n(-0.3*nDiff/15.762) - exp_n(-0.6*nDiff/15.762)))*nDiff, 0.5) / 8.61553; if (nSubsidy < 5) nSubsidy = 5; nSubsidy *= COIN; - if (fDebug && fDebugMagi) printf("@@GPoWR nHeight = %d, nSubsidy = %"PRI64d", nDiff = %f\n", + if (fDebug && fDebugMagi) printf("@@GPoWR nHeight = %d, nSubsidy = %" PRI64d ", nDiff = %f\n", nHeight, nSubsidy/COIN, nDiff); } else if (nHeight <= BLOCK_REWARD_ADJT_M7M_V2) { @@ -1197,7 +1197,7 @@ int64 GetProofOfWorkReward(int nBits, int nHeight, int64 nFees) * exp_n2(nDiff/0.08, nDiffcu/0.08); if (nSubsidy < 5) nSubsidy = 5; nSubsidy *= COIN; - if (fDebug && fDebugMagi) printf("@@GPoWR nHeight = %d, nSubsidy = %"PRI64d", nDiff = %f\n", + if (fDebug && fDebugMagi) printf("@@GPoWR nHeight = %d, nSubsidy = %" PRI64d ", nDiff = %f\n", nHeight, nSubsidy/COIN, nDiff); } else { @@ -1206,7 +1206,7 @@ int64 GetProofOfWorkReward(int nBits, int nHeight, int64 nFees) * exp_n2(nDiff/(0.08/M7Mv2_SCALE), nDiffcu/(0.08/M7Mv2_SCALE)); if (nSubsidy < 5) nSubsidy = 5; nSubsidy *= COIN; - if (fDebugMagi) printf("@@GPoWR nHeight = %d, nSubsidy = %"PRI64d", nDiff = %f\n", + if (fDebugMagi) printf("@@GPoWR nHeight = %d, nSubsidy = %" PRI64d ", nDiff = %f\n", nHeight, nSubsidy/COIN, nDiff); } } @@ -1217,7 +1217,7 @@ int64 GetProofOfWorkReward(int nBits, int nHeight, int64 nFees) * exp_n2(nDiff/(0.16/M7Mv2_SCALE), nDiffcu/(0.16/M7Mv2_SCALE)); if (nSubsidy < 3) nSubsidy = 3; nSubsidy *= COIN; - if (fDebug && fDebugMagi) printf("@@GPoWR nHeight = %d, nSubsidy = %"PRI64d", nDiff = %f\n", + if (fDebug && fDebugMagi) printf("@@GPoWR nHeight = %d, nSubsidy = %" PRI64d ", nDiff = %f\n", nHeight, nSubsidy/COIN, nDiff); // nSubsidy = 15. * 2500. / (pow((nDiff+500.)/10., 2.)); // if (nSubsidy < 3) nSubsidy = 3; @@ -1270,9 +1270,9 @@ int64 GetProofOfStakeReward(int64 nCoinAge, int64 nFees, CBlockIndex* pindex) int64 nSubsidy = nCoinAge * rAPR * COIN * 33 / (365 * 33 + 8); if (fDebug && GetBoolArg("-printcreation")) - printf("GetProofOfStakeReward(): create=%s nCoinAge=%"PRI64d" nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, pindex->nHeight); + printf("GetProofOfStakeReward(): create=%s nCoinAge=%" PRI64d " nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, pindex->nHeight); - if (fDebug && fDebugMagi) printf("@@GPoSR nHeight = %d, nSubsidy = %"PRI64d", nCoinAge = %"PRI64d", rAPR = %f\n", + if (fDebug && fDebugMagi) printf("@@GPoSR nHeight = %d, nSubsidy = %" PRI64d ", nCoinAge = %" PRI64d ", rAPR = %f\n", pindex->nHeight, nSubsidy/COIN, nCoinAge, rAPR); return nSubsidy + nFees; @@ -1386,12 +1386,12 @@ unsigned int GetNextTargetRequired_v1(const CBlockIndex* pindexLast, bool fProof int64 nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime(); if(nActualSpacing < 0) { - // printf(">> nActualSpacing = %"PRI64d" corrected to 1.\n", nActualSpacing); + // printf(">> nActualSpacing = %" PRI64d " corrected to 1.\n", nActualSpacing); nActualSpacing = 1; } else if(nActualSpacing > nTargetTimespan) { - // printf(">> nActualSpacing = %"PRI64d" corrected to nTargetTimespan (900).\n", nActualSpacing); + // printf(">> nActualSpacing = %" PRI64d " corrected to nTargetTimespan (900).\n", nActualSpacing); nActualSpacing = nTargetTimespan; } @@ -1406,9 +1406,9 @@ unsigned int GetNextTargetRequired_v1(const CBlockIndex* pindexLast, bool fProof bnNew /= ((nInterval + 1) * nTargetSpacing); /* - printf(">> Height = %d, fProofOfStake = %d, nInterval = %"PRI64d", nTargetSpacing = %"PRI64d", nActualSpacing = %"PRI64d"\n", + printf(">> Height = %d, fProofOfStake = %d, nInterval = %" PRI64d ", nTargetSpacing = %" PRI64d ", nActualSpacing = %" PRI64d "\n", pindexPrev->nHeight, fProofOfStake, nInterval, nTargetSpacing, nActualSpacing); - printf(">> pindexPrev->GetBlockTime() = %"PRI64d", pindexPrev->nHeight = %d, pindexPrevPrev->GetBlockTime() = %"PRI64d", pindexPrevPrev->nHeight = %d\n", + printf(">> pindexPrev->GetBlockTime() = %" PRI64d ", pindexPrev->nHeight = %d, pindexPrevPrev->GetBlockTime() = %" PRI64d ", pindexPrevPrev->nHeight = %d\n", pindexPrev->GetBlockTime(), pindexPrev->nHeight, pindexPrevPrev->GetBlockTime(), pindexPrevPrev->nHeight); */ @@ -1461,12 +1461,12 @@ unsigned int GetNextTargetRequired_v3(const CBlockIndex* pindexLast, bool fProof int64 nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime(); if(nActualSpacing < 0) { - // printf(">> nActualSpacing = %"PRI64d" corrected to 1.\n", nActualSpacing); + // printf(">> nActualSpacing = %" PRI64d " corrected to 1.\n", nActualSpacing); nActualSpacing = 1; } else if(nActualSpacing > nTargetTimespan0) { - // printf(">> nActualSpacing = %"PRI64d" corrected to nTargetTimespan0 (900).\n", nActualSpacing); + // printf(">> nActualSpacing = %" PRI64d " corrected to nTargetTimespan0 (900).\n", nActualSpacing); nActualSpacing = nTargetTimespan0; } @@ -1484,9 +1484,9 @@ unsigned int GetNextTargetRequired_v3(const CBlockIndex* pindexLast, bool fProof bnNew /= ((nInterval + 1) * nTargetSpacing0); /* - printf(">> Height = %d, fProofOfStake = %d, nInterval = %"PRI64d", nTargetSpacing0 = %"PRI64d", nActualSpacing = %"PRI64d"\n", + printf(">> Height = %d, fProofOfStake = %d, nInterval = %" PRI64d ", nTargetSpacing0 = %" PRI64d ", nActualSpacing = %" PRI64d "\n", pindexPrev->nHeight, fProofOfStake, nInterval, nTargetSpacing0, nActualSpacing); - printf(">> pindexPrev->GetBlockTime() = %"PRI64d", pindexPrev->nHeight = %d, pindexPrevPrev->GetBlockTime() = %"PRI64d", pindexPrevPrev->nHeight = %d\n", + printf(">> pindexPrev->GetBlockTime() = %" PRI64d ", pindexPrev->nHeight = %d, pindexPrevPrev->GetBlockTime() = %" PRI64d ", pindexPrevPrev->nHeight = %d\n", pindexPrev->GetBlockTime(), pindexPrev->nHeight, pindexPrevPrev->GetBlockTime(), pindexPrevPrev->nHeight); */ @@ -1853,7 +1853,7 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map& mapTes // Revisit this if/when transaction replacement is implemented and allows // adding inputs: fInvalid = true; - return DoS(100, error("FetchInputs() : %s prevout.n out of range %d %"PRIszu" %"PRIszu" prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); + return DoS(100, error("FetchInputs() : %s prevout.n out of range %d %" PRIszu " %" PRIszu " prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); } } @@ -1926,7 +1926,7 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs, CTransaction& txPrev = inputs[prevout.hash].second; if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) - return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %"PRIszu" %"PRIszu" prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); + return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %" PRIszu " %" PRIszu " prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); // If prev is coinbase or coinstake, check that it's matured if (txPrev.IsCoinBase() || txPrev.IsCoinStake()) @@ -2184,7 +2184,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) GetProofOfWorkReward(pindex->pprev->nBits, pindex->pprev->nHeight, nFees); // Check coinbase reward if (vtx[0].GetValueOut() > nPoWReward) - return DoS(50, error("ConnectBlock() : coinbase reward exceeded (actual=%"PRI64d" vs calculated=%"PRI64d", height=%i)", + return DoS(50, error("ConnectBlock() : coinbase reward exceeded (actual=%" PRI64d " vs calculated=%" PRI64d ", height=%i)", vtx[0].GetValueOut(), nPoWReward, pindex->pprev->nHeight)); @@ -2206,7 +2206,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) // } int64 nPoSReward = GetProofOfStakeReward(nCoinAge, nFees, pindex->pprev); if (nStakeReward > nPoSReward) - return DoS(100, error("ConnectBlock() : stake reward exceeded (actual=%"PRI64d" vs calculated=%"PRI64d", height=%i)", nStakeReward, nPoSReward, pindex->nHeight)); + return DoS(100, error("ConnectBlock() : stake reward exceeded (actual=%" PRI64d " vs calculated=%" PRI64d ", height=%i)", nStakeReward, nPoSReward, pindex->nHeight)); } @@ -2219,7 +2219,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) // ppcoin: fees are not collected by miners as in bitcoin // ppcoin: fees are destroyed to compensate the entire network if (fDebug && GetBoolArg("-printcreation")) - printf("ConnectBlock() : destroy=%s nFees=%"PRI64d"\n", FormatMoney(nFees).c_str(), nFees); + printf("ConnectBlock() : destroy=%s nFees=%" PRI64d "\n", FormatMoney(nFees).c_str(), nFees); if (fJustCheck) return true; @@ -2278,8 +2278,8 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) vConnect.push_back(pindex); reverse(vConnect.begin(), vConnect.end()); - printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); - printf("REORGANIZE: Connect %"PRIszu" blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); + printf("REORGANIZE: Disconnect %" PRIszu " blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); + printf("REORGANIZE: Connect %" PRIszu " blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); // Disconnect shorter branch vector vResurrect; @@ -2408,7 +2408,7 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) } if (!vpindexSecondary.empty()) - printf("Postponing %"PRIszu" reconnects\n", vpindexSecondary.size()); + printf("Postponing %" PRIszu " reconnects\n", vpindexSecondary.size()); // Switch to new best branch if (!Reorganize(txdb, pindexIntermediate)) @@ -2454,7 +2454,7 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) bnBestChainTrust = pindexNew->bnChainTrust; nTimeBestReceived = GetTime(); nTransactionsUpdated++; - printf("SetBestChain: new best=%s height=%d money supply=%"PRI64d" trust=%s date=%s\n", + printf("SetBestChain: new best=%s height=%d money supply=%" PRI64d " trust=%s date=%s\n", hashBestChain.ToString().c_str(), nBestHeight, (pindexBest->nMoneySupply)/COIN, bnBestChainTrust.ToString().c_str(), DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); @@ -2540,10 +2540,10 @@ bool CTransaction::GetCoinAgeV2(CTxDB& txdb, uint64& nCoinAge) const CBigNum bnCoinDayPrint = CBigNum(nValueIn) * nTimeWeight / COIN / (24 * 60 * 60); if (fDebugMagiPoS) - printf("@Tx.GetCoinAgeV2 -> nValueIn=%"PRI64d" txPrev.nTime=%d nTimeDiff=%d nTimeDiff=%d bnCoinDay=%s\n", nValueIn / COIN, txPrev.nTime, nTime, nTime - txPrev.nTime, bnCoinDayPrint.ToString().c_str()); + printf("@Tx.GetCoinAgeV2 -> nValueIn=%" PRI64d " txPrev.nTime=%d nTimeDiff=%d nTimeDiff=%d bnCoinDay=%s\n", nValueIn / COIN, txPrev.nTime, nTime, nTime - txPrev.nTime, bnCoinDayPrint.ToString().c_str()); 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=%" PRI64d " nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString().c_str()); } CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60); @@ -2589,10 +2589,10 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const CBigNum bnCoinDayPrint = CBigNum(nValueIn) * nTimeWeight / COIN / (24 * 60 * 60); if (fDebugMagiPoS) - printf("@Tx.GetCoinAge -> nValueIn=%"PRI64d" txPrev.nTime=%d nTimeDiff=%d nTimeDiff=%d bnCoinDay=%s\n", nValueIn / COIN, txPrev.nTime, nTime, nTime - txPrev.nTime, bnCoinDayPrint.ToString().c_str()); + printf("@Tx.GetCoinAge -> nValueIn=%" PRI64d " txPrev.nTime=%d nTimeDiff=%d nTimeDiff=%d bnCoinDay=%s\n", nValueIn / COIN, txPrev.nTime, nTime, nTime - txPrev.nTime, bnCoinDayPrint.ToString().c_str()); 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=%" PRI64d " nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString().c_str()); } CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60); @@ -2620,7 +2620,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=%" PRI64d "\n", nCoinAge); return true; } @@ -2666,7 +2666,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos) 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" PRI64x, pindexNew->nHeight, nStakeModifier); // Add to mapBlockIndex map::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; @@ -2833,7 +2833,7 @@ bool CBlock::AcceptBlock() int nHeight = pindexPrev->nHeight+1; // Check proof of work matches claimed amount - printf("Block %i BlockTime=%"PRI64d" CurrTime=%"PRI64d" AdjustedTime=%"PRI64d" vtx[0].nTime=%"PRI64d"\n", nHeight, GetBlockTime(), GetTime(), GetAdjustedTime(), (int64)vtx[0].nTime); + printf("Block %i BlockTime=%" PRI64d " CurrTime=%" PRI64d " AdjustedTime=%" PRI64d " vtx[0].nTime=%" PRI64d "\n", nHeight, GetBlockTime(), GetTime(), GetAdjustedTime(), (int64)vtx[0].nTime); if (IsChainAtSwitchPoint(nHeight) && GetTime() < (GetBlockTime() - 15)) return DoS(100, error("AcceptBlock() : chain switch point reached")); @@ -2866,7 +2866,7 @@ bool CBlock::AcceptBlock() return DoS(100, error("AcceptBlock() : proof-of-stake block violation (prior PoW not seen in the last five blocks or wait 3 mins) (height = %d)", nHeight)); // if (IsProofOfStake() && !CheckMoneySupply(pindexPrev)) -// return DoS(100, error("AcceptBlock() : Wrong Money Supply = %"PRI64d" at height %d", pindexPrev->nMoneySupply, nHeight-1)); +// return DoS(100, error("AcceptBlock() : Wrong Money Supply = %" PRI64d " at height %d", pindexPrev->nMoneySupply, nHeight-1)); // Check proof-of-work or proof-of-stake if (nBits != GetNextTargetRequired(pindexPrev, IsProofOfStake())) @@ -3417,7 +3417,7 @@ void PrintBlockTree() // print item CBlock block; block.ReadFromDisk(pindex); - printf("%d (%u,%u) %s %08x %s mint %7s tx %"PRIszu"", + printf("%d (%u,%u) %s %08x %s mint %7s tx %" PRIszu "", pindex->nHeight, pindex->nFile, pindex->nBlockPos, @@ -3502,7 +3502,7 @@ bool LoadExternalBlockFile(FILE* fileIn) __PRETTY_FUNCTION__); } } - printf("Loaded %i blocks from external file in %"PRI64d"ms\n", nLoaded, GetTimeMillis() - nStart); + printf("Loaded %i blocks from external file in %" PRI64d "ms\n", nLoaded, GetTimeMillis() - nStart); return nLoaded > 0; } @@ -3634,7 +3634,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) static map mapReuseKey; RandAddSeedPerfmon(); if (fDebug) - printf("received: %s (%"PRIszu" bytes)\n", strCommand.c_str(), vRecv.size()); + printf("received: %s (%" PRIszu " bytes)\n", strCommand.c_str(), vRecv.size()); if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) { printf("dropmessagestest DROPPING RECV MESSAGE\n"); @@ -3799,7 +3799,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (vAddr.size() > 1000) { pfrom->Misbehaving(20); - return error("message addr size() = %"PRIszu"", vAddr.size()); + return error("message addr size() = %" PRIszu "", vAddr.size()); } // Store the new addresses @@ -3862,7 +3862,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (vInv.size() > MAX_INV_SZ) { pfrom->Misbehaving(20); - return error("message inv size() = %"PRIszu"", vInv.size()); + return error("message inv size() = %" PRIszu "", vInv.size()); } // find last block in inv vector @@ -3912,11 +3912,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (vInv.size() > MAX_INV_SZ) { pfrom->Misbehaving(20); - return error("message getdata size() = %"PRIszu"", vInv.size()); + return error("message getdata size() = %" PRIszu "", vInv.size()); } if (fDebugNet || (vInv.size() != 1)) - printf("received getdata (%"PRIszu" invsz)\n", vInv.size()); + printf("received getdata (%" PRIszu " invsz)\n", vInv.size()); BOOST_FOREACH(const CInv& inv, vInv) { @@ -4327,7 +4327,7 @@ bool ProcessMessages(CNode* pfrom) break; } if (pstart - vRecv.begin() > 0) - printf("\n\nPROCESSMESSAGE SKIPPED %"PRIpdd" BYTES\n\n", pstart - vRecv.begin()); + printf("\n\nPROCESSMESSAGE SKIPPED %" PRIpdd " BYTES\n\n", pstart - vRecv.begin()); vRecv.erase(vRecv.begin(), pstart); // Read header @@ -4723,7 +4723,7 @@ if (fTestNet || pindexBest->nHeight >= 131100) { CTransaction txCoinStake; int64 nSearchTime = txCoinStake.nTime; // search to current time if (fDebugMagiPoS) - printf("@CreateNewBlock -> txCoinStake.nTime=%"PRI64d"\n", txCoinStake.nTime); + printf("@CreateNewBlock -> txCoinStake.nTime=%" PRI64d "\n", txCoinStake.nTime); if (nSearchTime > nLastCoinStakeSearchTime) { // printf(">>> OK1\n"); @@ -4736,7 +4736,7 @@ if (fTestNet || pindexBest->nHeight >= 131100) { pblock->vtx[0].nTime = txCoinStake.nTime; pblock->vtx.push_back(txCoinStake); if (fDebugMagiPoS) - printf("@CreateNewBlock-PoS found -> txCoinStake.nTime=%"PRI64d"\n", txCoinStake.nTime); + printf("@CreateNewBlock-PoS found -> txCoinStake.nTime=%" PRI64d "\n", txCoinStake.nTime); } } nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime; @@ -4937,7 +4937,7 @@ if (fTestNet || pindexBest->nHeight >= 131100) { nLastBlockSize = nBlockSize; if (fDebug && GetBoolArg("-printpriority")) - printf("CreateNewBlock(): total size %"PRI64u"\n", nBlockSize); + printf("CreateNewBlock(): total size %" PRI64u "\n", nBlockSize); if (!fTestNet && pindexBest->nHeight < 131100) { if (fProofOfStake) // attempt to find a coinstake @@ -4983,7 +4983,7 @@ if (!fTestNet && pindexBest->nHeight < 131100) { pblock->nTime = max(pblock->GetBlockTime(), PastDrift(pindexPrev->GetBlockTime(), pindexPrev->nHeight+1)); if (fDebug) { - printf("NewBlock: MedianPast=%"PRI64d" MaxTransTime=%"PRI64d" vtx[0].nTime=%"PRI64d" PastDrift=%"PRI64d" BlockTime=%"PRI64d"\n", + printf("NewBlock: MedianPast=%" PRI64d " MaxTransTime=%" PRI64d " vtx[0].nTime=%" PRI64d " PastDrift=%" PRI64d " BlockTime=%" PRI64d "\n", pindexPrev->GetMedianTimePast()+1, nMaxTransactionTime, (int64)pblock->vtx[0].nTime, @@ -5173,7 +5173,7 @@ void MagiMiner(CWallet *pwallet, bool fProofOfStake) continue; } - printf("Running MagiMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(), + printf("Running MagiMiner with %" PRIszu " transactions in block (%u bytes)\n", pblock->vtx.size(), ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); // diff --git a/src/main.h b/src/main.h index eab409a385..2aa8f61f5f 100644 --- a/src/main.h +++ b/src/main.h @@ -737,7 +737,7 @@ class CTransaction { std::string str; str += IsCoinBase()? "Coinbase" : (IsCoinStake()? "Coinstake" : "CTransaction"); - str += strprintf("(hash=%s, nTime=%d, ver=%d, vin.size=%"PRIszu", vout.size=%"PRIszu", nLockTime=%d)\n", + str += strprintf("(hash=%s, nTime=%d, ver=%d, vin.size=%" PRIszu ", vout.size=%" PRIszu ", nLockTime=%d)\n", GetHash().ToString().substr(0,10).c_str(), nTime, nVersion, @@ -1175,7 +1175,7 @@ class CBlock void print() const { - printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu", vchBlockSig=%s)\n", + printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%" PRIszu ", vchBlockSig=%s)\n", GetHash().ToString().c_str(), nVersion, hashPrevBlock.ToString().c_str(), @@ -1430,7 +1430,7 @@ class CBlockIndex std::string ToString() const { - return strprintf("CBlockIndex(nprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016"PRI64x", nStakeModifierChecksum=%08x, hashProofOfStake=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)", + return strprintf("CBlockIndex(nprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016" PRI64x ", nStakeModifierChecksum=%08x, hashProofOfStake=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)", pprev, pnext, nFile, nBlockPos, nHeight, FormatMoney(nMint).c_str(), FormatMoney(nMoneySupply).c_str(), GeneratedStakeModifier() ? "MOD" : "-", GetStakeEntropyBit(), IsProofOfStake()? "PoS" : "PoW", diff --git a/src/net.cpp b/src/net.cpp index 3bfddaa9d5..59d9b24d63 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -891,7 +891,7 @@ void ThreadSocketHandler2(void* parg) if (nPos > ReceiveBufferSize()) { if (!pnode->fDisconnect) - printf("socket recv flood control disconnect (%"PRIszu" bytes)\n", vRecv.size()); + printf("socket recv flood control disconnect (%" PRIszu " bytes)\n", vRecv.size()); pnode->CloseSocketDisconnect(); } else { @@ -1236,7 +1236,7 @@ void DumpAddresses() CAddrDB adb; adb.Write(addrman); - printf("Flushed %d addresses to peers.dat %"PRI64d"ms\n", + printf("Flushed %d addresses to peers.dat %" PRI64d "ms\n", addrman.size(), GetTimeMillis() - nStart); } diff --git a/src/net.h b/src/net.h index 0b2a8aefaa..dcb4cfcd0d 100644 --- a/src/net.h +++ b/src/net.h @@ -322,7 +322,7 @@ class CNode // the key is the earliest time the request can be sent int64& nRequestTime = mapAlreadyAskedFor[inv]; if (fDebugNet) - printf("askfor %s %"PRI64d" (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str()); + printf("askfor %s %" PRI64d " (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str()); // Make sure not to reuse time indexes to keep things in the same order int64 nNow = (GetTime() - 1) * 1000000; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index cfb9ef9b22..c771c8d100 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -179,7 +179,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": ""))); result.push_back(Pair("proofhash", blockindex->IsProofOfStake()? blockindex->hashProofOfStake.GetHex() : blockindex->GetBlockHash().GetHex())); result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit())); - result.push_back(Pair("modifier", strprintf("%016"PRI64x, blockindex->nStakeModifier))); + result.push_back(Pair("modifier", strprintf("%016" PRI64x, blockindex->nStakeModifier))); result.push_back(Pair("modifierchecksum", strprintf("%08x", blockindex->nStakeModifierChecksum))); Array txinfo; BOOST_FOREACH (const CTransaction& tx, block.vtx) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 5034be669a..d56aa23a79 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -550,7 +550,7 @@ if (fDebug && fDebugMagi) printf("nTime: %i\n", pblock->nTime); printf("nBits: %i\n", pblock->nBits); printf("nNonce: %i\n", pblock->nNonce); -// printf("nPrevMoneySupply: %"PRI64d"\n", pblock->nPrevMoneySupply); +// printf("nPrevMoneySupply: %" PRI64d "\n", pblock->nPrevMoneySupply); printf("-----------------\n"); printf("hashTarget: 0x%s\n", hashTarget.GetHex().c_str()); printf(">>$ work sent (bytes swapped): \n"); diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index cdef754215..e7fca464ea 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -52,7 +52,7 @@ Value getpeerinfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("addr", stats.addrName)); - obj.push_back(Pair("services", strprintf("%08"PRI64x, stats.nServices))); + obj.push_back(Pair("services", strprintf("%08" PRI64x, stats.nServices))); obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend)); obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv)); obj.push_back(Pair("conntime", (boost::int64_t)stats.nTimeConnected)); diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 07fee71073..26e2e95e7e 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -817,7 +817,7 @@ Value addmultisigaddress(const Array& params, bool fHelp) if ((int)keys.size() < nRequired) throw runtime_error( strprintf("not enough keys supplied " - "(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired)); + "(got %" PRIszu " keys, but need at least %d to redeem)", keys.size(), nRequired)); std::vector pubkeys; pubkeys.resize(keys.size()); for (unsigned int i = 0; i < keys.size(); i++) diff --git a/src/txdb.cpp b/src/txdb.cpp index 84b7e9f40f..a2abe65987 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -353,7 +353,7 @@ bool CTxDB::LoadBlockIndex() // Calculate stake modifier checksum pindex->nStakeModifierChecksum = GetStakeModifierChecksum(pindex); if (!fTestNet && !CheckStakeModifierCheckpoints(pindex->nHeight, pindex->nStakeModifierChecksum)) - return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016"PRI64x, pindex->nHeight, pindex->nStakeModifier); + return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016" PRI64x, pindex->nHeight, pindex->nStakeModifier); } // Load hashBestChain pointer to end of best chain diff --git a/src/util.cpp b/src/util.cpp index d49b27a396..fee7ab2c6e 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -381,7 +381,7 @@ string FormatMoney(int64 n, bool fPlus) int64 n_abs = (n > 0 ? n : -n); int64 quotient = n_abs/COIN; int64 remainder = n_abs%COIN; - string str = strprintf("%"PRI64d".%06"PRI64d, quotient, remainder); + string str = strprintf("%" PRI64d ".%06" PRI64d, quotient, remainder); // Right-trim excess zeros before the decimal point: int nTrim = 0; @@ -1283,7 +1283,7 @@ void AddTimeData(const CNetAddr& ip, int64 nTime) // Add data vTimeOffsets.input(nOffsetSample); - printf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); + printf("Added time data, samples %d, offset %+" PRI64d " (%+" PRI64d " minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1) { int64 nMedian = vTimeOffsets.median(); @@ -1318,10 +1318,10 @@ void AddTimeData(const CNetAddr& ip, int64 nTime) } if (fDebug) { BOOST_FOREACH(int64 n, vSorted) - printf("%+"PRI64d" ", n); + printf("%+" PRI64d " ", n); printf("| "); } - printf("nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60); + printf("nTimeOffset = %+" PRI64d " (%+" PRI64d " minutes)\n", nTimeOffset, nTimeOffset/60); } } diff --git a/src/util.h b/src/util.h index 3b564c0a71..13752e2b3d 100644 --- a/src/util.h +++ b/src/util.h @@ -255,7 +255,7 @@ extern const char *feedbackUrl; inline std::string i64tostr(int64 n) { - return strprintf("%"PRI64d, n); + return strprintf("%" PRI64d, n); } inline std::string itostr(int n) diff --git a/src/wallet.cpp b/src/wallet.cpp index f19c22baf0..4e9e726a22 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -847,7 +847,7 @@ void CWallet::ReacceptWalletTransactions() // Update fSpent if a tx got spent somewhere else by a copy of wallet.dat if (txindex.vSpent.size() != wtx.vout.size()) { - printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %"PRIszu" != wtx.vout.size() %"PRIszu"\n", txindex.vSpent.size(), wtx.vout.size()); + printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %" PRIszu " != wtx.vout.size() %" PRIszu "\n", txindex.vSpent.size(), wtx.vout.size()); continue; } for (unsigned int i = 0; i < txindex.vSpent.size(); i++) @@ -1417,7 +1417,7 @@ bool CWallet::GetStakeWeight(uint64& nMinWeight, uint64& nMaxWeight, uint64& nWe GetMagiWeight(txPrev.vout[prevout.n].nValue, (int64)pcoin.first->nTime, (int64)GetTime()); CBigNum bnCoinDayWeight = CBigNum(pcoin.first->vout[pcoin.second].nValue) * nTimeWeight / COIN / (24 * 60 * 60); if (fDebugMagiPoS) - printf("@CWallet::GetStakeWeight -> %"PRI64d" %"PRI64d" %"PRI64d" %"PRI64d"\n", txPrev.vout[prevout.n].nValue, pcoin.first->vout[pcoin.second].nValue, (int64)pcoin.first->nTime, (int64)GetTime()); + printf("@CWallet::GetStakeWeight -> %" PRI64d " %" PRI64d " %" PRI64d " %" PRI64d "\n", txPrev.vout[prevout.n].nValue, pcoin.first->vout[pcoin.second].nValue, (int64)pcoin.first->nTime, (int64)GetTime()); // Weight is greater than zero if (nTimeWeight > 0) @@ -1498,7 +1498,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int GetMagiWeightV2(txPrev.vout[prevout.n].nValue, block.GetBlockTime(), (int64)(txNew.nTime - nMaxStakeSearchInterval)) : GetMagiWeight(txPrev.vout[prevout.n].nValue, block.GetBlockTime(), (int64)(txNew.nTime - nMaxStakeSearchInterval)); - if (fDebugMagi && (pindexBest->nHeight%10 == 0)) printf(">* CreateCoinStake : block.GetBlockTime() = %"PRI64d", nStakeMinAge = %d, txNew.nTime = %d, nTimeWeight = %"PRI64d" \n", block.GetBlockTime(), GetStakeMinAge((int64)(txNew.nTime - nMaxStakeSearchInterval)), txNew.nTime, nTimeWeight); + if (fDebugMagi && (pindexBest->nHeight%10 == 0)) printf(">* CreateCoinStake : block.GetBlockTime() = %" PRI64d ", nStakeMinAge = %d, txNew.nTime = %d, nTimeWeight = %" PRI64d " \n", block.GetBlockTime(), GetStakeMinAge((int64)(txNew.nTime - nMaxStakeSearchInterval)), txNew.nTime, nTimeWeight); if (nTimeWeight < GetStakeMinAge((int64)(txNew.nTime - nMaxStakeSearchInterval))) continue; // only count coins meeting min age requirement @@ -1553,7 +1553,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); nCredit += nCoinStakeValue; -// if (fDebugMagi) printf(">* CreateCoinStake : nCredit = %"PRI64d"\n", nCredit); +// if (fDebugMagi) printf(">* CreateCoinStake : nCredit = %" PRI64d "\n", nCredit); vwtxPrev.push_back(pcoin.first); txNew.vout.push_back(CTxOut(0, scriptPubKeyOut)); // stake @@ -1580,7 +1580,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int } if (nCredit == 0 || nCredit > nBalance - nReserveBalance) { - // printf(">> Wallet: CreateCoinStake: nCredit = %"PRI64d", nBalance = %"PRI64d", nReserveBalance = %"PRI64d"\n", nCredit, nBalance, nReserveBalance); + // printf(">> Wallet: CreateCoinStake: nCredit = %" PRI64d ", nBalance = %" PRI64d ", nReserveBalance = %" PRI64d "\n", nCredit, nBalance, nReserveBalance); return false; } @@ -1610,22 +1610,37 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int * should be available externally, e.g., RPC command, magi.conf configuration file. ** Magi, for optimum staking, nStakeCombineThreshold should be used in combination with nStakeSplitThreshold.*/ if (nCredit > nStakeCombineThreshold * COIN) + { break; + } int64 nCoinStakeValue = pcoin.first->vout[pcoin.second].nValue; // Stop adding inputs if reached reserve limit + + if (nCredit + nCoinStakeValue > nBalance - nReserveBalance) + { break; + } // Do not add single input which is already greater than nStakeCombineThreshold + + if (nCoinStakeValue > nStakeCombineThreshold * COIN) + { continue; - // Do not add input that is still too young - CTransaction txPrev=*pcoin.first; - COutPoint prevout = COutPoint(pcoin.first->GetHash(), pcoin.second); - int64 nTimeWeight = (IsPoSIIProtocolV2(nHeightV2)) ? - GetMagiWeightV2(txPrev.vout[prevout.n].nValue, (int64)pcoin.first->nTime, (int64)txNew.nTime) : - GetMagiWeight(txPrev.vout[prevout.n].nValue, (int64)pcoin.first->nTime, (int64)txNew.nTime); + } + // Do not add input that is still too young + + + CTransaction txPrev=*pcoin.first; + COutPoint prevout = COutPoint(pcoin.first->GetHash(), pcoin.second); + int64 nTimeWeight = (IsPoSIIProtocolV2(nHeightV2)) ? + GetMagiWeightV2(txPrev.vout[prevout.n].nValue, (int64)pcoin.first->nTime, (int64)txNew.nTime) : + GetMagiWeight(txPrev.vout[prevout.n].nValue, (int64)pcoin.first->nTime, (int64)txNew.nTime); + if ( nTimeWeight < GetStakeMinAge((int64)txNew.nTime) ) + { continue; + } txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); nCredit += nCoinStakeValue; vwtxPrev.push_back(pcoin.first); @@ -1650,7 +1665,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int return error("CreateCoinStake : failed to calculate coin age"); nCredit += GetProofOfStakeReward(nCoinAge, nFees, pindexBest); if (fDebugMagiPoS) - printf("@Coin stake -> nCoinAge=%"PRI64d" StakeReward=%f\n", nCoinAge, ((double)(GetProofOfStakeReward(nCoinAge, nFees, pindexBest)))/((double)COIN)); + printf("@Coin stake -> nCoinAge=%" PRI64d " StakeReward=%f\n", nCoinAge, ((double)(GetProofOfStakeReward(nCoinAge, nFees, pindexBest)))/((double)COIN)); } int64 nMinFee = 0; @@ -1859,12 +1874,12 @@ void CWallet::PrintWallet(const CBlock& block) if (block.IsProofOfWork() && mapWallet.count(block.vtx[0].GetHash())) { CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()]; - printf(" mine: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); + printf(" mine: %d %d %" PRI64d "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); } if (block.IsProofOfStake() && mapWallet.count(block.vtx[1].GetHash())) { CWalletTx& wtx = mapWallet[block.vtx[1].GetHash()]; - printf(" stake: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); + printf(" stake: %d %d %" PRI64d "", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); } } @@ -1927,7 +1942,7 @@ bool CWallet::NewKeyPool() walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey())); setKeyPool.insert(nIndex); } - printf("CWallet::NewKeyPool wrote %"PRI64d" new keys\n", nKeys); + printf("CWallet::NewKeyPool wrote %" PRI64d " new keys\n", nKeys); } return true; } @@ -1952,7 +1967,7 @@ bool CWallet::TopUpKeyPool() if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey()))) throw runtime_error("TopUpKeyPool() : writing generated key failed"); setKeyPool.insert(nEnd); - printf("keypool added key %"PRI64d", size=%"PRIszu"\n", nEnd, setKeyPool.size()); + printf("keypool added key %" PRI64d ", size=%" PRIszu "\n", nEnd, setKeyPool.size()); } } return true; @@ -1982,7 +1997,7 @@ void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool) throw runtime_error("ReserveKeyFromKeyPool() : unknown key in key pool"); assert(keypool.vchPubKey.IsValid()); if (fDebug && GetBoolArg("-printkeypool")) - printf("keypool reserve %"PRI64d"\n", nIndex); + printf("keypool reserve %" PRI64d "\n", nIndex); } } @@ -2010,7 +2025,7 @@ void CWallet::KeepKey(int64 nIndex) walletdb.ErasePool(nIndex); } if(fDebug) - printf("keypool keep %"PRI64d"\n", nIndex); + printf("keypool keep %" PRI64d "\n", nIndex); } void CWallet::ReturnKey(int64 nIndex) @@ -2021,7 +2036,7 @@ void CWallet::ReturnKey(int64 nIndex) setKeyPool.insert(nIndex); } // if(fDebug) -// printf("keypool return %"PRI64d"\n", nIndex); +// printf("keypool return %" PRI64d "\n", nIndex); } bool CWallet::GetKeyFromPool(CPubKey& result, bool fAllowReuse) diff --git a/src/walletdb.cpp b/src/walletdb.cpp index 68a3b03c1b..7aef84bbd0 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -237,7 +237,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue, //// debug print //printf("LoadWallet %s\n", wtx.GetHash().ToString().c_str()); - //printf(" %12"PRI64d" %s %s %s\n", + //printf(" %12" PRI64d " %s %s %s\n", // wtx.vout[0].nValue, // DateTimeStrFormat("%x %H:%M:%S", wtx.GetBlockTime()).c_str(), // wtx.hashBlock.ToString().substr(0,20).c_str(), @@ -536,7 +536,7 @@ void ThreadFlushWalletDB(void* parg) bitdb.CheckpointLSN(strFile); bitdb.mapFileUseCount.erase(mi++); - printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart); + printf("Flushed wallet.dat %" PRI64d "ms\n", GetTimeMillis() - nStart); } } } @@ -597,7 +597,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys) // Set -rescan so any missing transactions will be // found. int64 now = GetTime(); - std::string newFilename = strprintf("wallet.%"PRI64d".bak", now); + std::string newFilename = strprintf("wallet.%" PRI64d ".bak", now); int result = dbenv.dbenv.dbrename(NULL, filename.c_str(), NULL, newFilename.c_str(), DB_AUTO_COMMIT); @@ -616,7 +616,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys) printf("Salvage(aggressive) found no records in %s.\n", newFilename.c_str()); return false; } - printf("Salvage(aggressive) found %"PRIszu" records\n", salvagedData.size()); + printf("Salvage(aggressive) found %" PRIszu " records\n", salvagedData.size()); bool fSuccess = allOK; Db* pdbCopy = new Db(&dbenv.dbenv, 0);