From 09f2a990950512cbe418526d91838887a0dded2a Mon Sep 17 00:00:00 2001 From: Scott Nadal Date: Tue, 10 Jul 2012 16:08:27 +0100 Subject: [PATCH] PPCoin: Version number and rename checkpoint related constants --- src/bitcoinrpc.cpp | 2 +- src/checkpoints.cpp | 5 ++--- src/checkpoints.h | 6 ++---- src/main.cpp | 12 ++++++------ src/serialize.h | 2 ++ src/util.cpp | 2 +- src/wallet.cpp | 4 ++-- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index e68f1fe..60c5449 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -307,7 +307,7 @@ Value getinfo(const Array& params, bool fHelp) "Returns an object containing various state info."); Object obj; - obj.push_back(Pair("version", (int)VERSION)); + obj.push_back(Pair("version", FormatFullVersion())); obj.push_back(Pair("balance", ValueFromAmount(pwalletMain->GetBalance()))); obj.push_back(Pair("newmint", ValueFromAmount(pwalletMain->GetNewMint()))); obj.push_back(Pair("stake", ValueFromAmount(pwalletMain->GetStake()))); diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 6c28158..d004c84 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -188,9 +188,9 @@ namespace Checkpoints uint256 AutoSelectSyncCheckpoint() { - // select block roughly 8 hours ago + // select a block some time ago CBlockIndex *pindex = mapBlockIndex[hashSyncCheckpoint]; - while (pindex->pnext && pindex->pnext->GetBlockTime() + AUTO_CHECKPOINT_MIN_SPAN <= GetAdjustedTime()) + while (pindex->pnext && pindex->pnext->GetBlockTime() + CHECKPOINT_MIN_SPAN <= GetAdjustedTime()) pindex = pindex->pnext; return pindex->GetBlockHash(); } @@ -265,7 +265,6 @@ namespace Checkpoints hashPendingCheckpoint = hash; checkpointMessagePending.SetNull(); printf("ResetSyncCheckpoint: pending for sync-checkpoint %s\n", hashPendingCheckpoint.ToString().c_str()); - // TODO: when to ask for the checkpoint chain? } BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints) diff --git a/src/checkpoints.h b/src/checkpoints.h index 35cbc65..c09e568 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -8,10 +8,8 @@ #include #include "util.h" -// ppcoin: auto checkpoint min at 8 hours; max at 16 hours -#define AUTO_CHECKPOINT_MIN_SPAN (60 * 60 * 8) -#define AUTO_CHECKPOINT_MAX_SPAN (60 * 60 * 16) -#define AUTO_CHECKPOINT_TRUST_SPAN (60 * 60 * 24) +#define STAKE_MIN_AGE (60 * 60 * 24) // minimum age for coin age +#define CHECKPOINT_MIN_SPAN (60 * 60 * 4) // 4 hours checkpoint class uint256; class CBlockIndex; diff --git a/src/main.cpp b/src/main.cpp index b09357a..aaf3f36 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1338,8 +1338,8 @@ bool CTransaction::CheckProofOfStake(unsigned int nBits) const CBlock block; if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) return false; // unable to read block of previous transaction - if (block.GetBlockTime() + AUTO_CHECKPOINT_TRUST_SPAN > nTime) - return false; // only count coins from at least one week ago + if (block.GetBlockTime() + STAKE_MIN_AGE > nTime) + return false; // only count coins meeting min age requirement int64 nValueIn = txPrev.vout[txin.prevout.n].nValue; CBigNum bnCoinDay = CBigNum(nValueIn) * (nTime-txPrev.nTime) / COIN / (24 * 60 * 60); @@ -1353,10 +1353,10 @@ bool CTransaction::CheckProofOfStake(unsigned int nBits) const } // ppcoin: total coin age spent in transaction, in the unit of coin-days. -// Only those coins last spent at least a week ago count. As those +// Only those coins meeting minimum age requirement counts. As those // transactions not in main chain are not currently indexed so we // might not find out about their coin age. Older transactions are -// guaranteed to be in main chain by auto checkpoint. This rule is +// 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 @@ -1381,8 +1381,8 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const CBlock block; if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) return false; // unable to read block of previous transaction - if (block.GetBlockTime() + AUTO_CHECKPOINT_TRUST_SPAN > nTime) - continue; // only count coins from at least one week ago + if (block.GetBlockTime() + STAKE_MIN_AGE > nTime) + continue; // only count coins meeting min age requirement int64 nValueIn = txPrev.vout[txin.prevout.n].nValue; bnCentSecond += CBigNum(nValueIn) * (nTime-txPrev.nTime) / CENT; diff --git a/src/serialize.h b/src/serialize.h index dafc4b1..61120fd 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -65,6 +65,8 @@ static const int VERSION = 50100; static const char* pszSubVer = ""; static const bool VERSION_IS_BETA = true; +static const int PPCOIN_VERSION = 100; + // Used to bypass the rule against non-const reference to temporary // where it makes sense with wrappers such as CFlatData or CTxDB template diff --git a/src/util.cpp b/src/util.cpp index 1082899..18d0ce8 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1017,7 +1017,7 @@ string FormatVersion(int nVersion) string FormatFullVersion() { - string s = FormatVersion(VERSION) + pszSubVer; + string s = FormatVersion(PPCOIN_VERSION) + pszSubVer; if (VERSION_IS_BETA) { s += "-"; s += _("beta"); diff --git a/src/wallet.cpp b/src/wallet.cpp index bab18b6..12fb9fd 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1115,8 +1115,8 @@ bool CWallet::CreateCoinStake(unsigned int nBits, CTransaction& txNew) CBlock block; if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) continue; - if (block.GetBlockTime() + AUTO_CHECKPOINT_TRUST_SPAN > txNew.nTime) - continue; // only count coins from at least one week ago + if (block.GetBlockTime() + STAKE_MIN_AGE > txNew.nTime) + continue; // only count coins meeting min age requirement int64 nValueIn = pcoin.first->vout[pcoin.second].nValue; CBigNum bnCoinDay = CBigNum(nValueIn) * (txNew.nTime-pcoin.first->nTime) / COIN / (24 * 60 * 60); -- 1.7.1