#include <boost/asio/ip/v6_only.hpp>
#include <boost/bind.hpp>
#include <boost/filesystem.hpp>
+
#include <boost/iostreams/concepts.hpp>
#include <boost/iostreams/stream.hpp>
#include <boost/algorithm/string.hpp>
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <boost/assign/list_of.hpp> // for 'map_list_of()'
#include <algorithm>
#include "checkpoints.h"
#include "main.h"
#include "uint256.h"
+using namespace std;
+
namespace Checkpoints
{
- typedef std::map<int, std::pair<uint256, unsigned int> > MapCheckpoints;
- typedef std::list<uint256> ListBannedBlocks;
+ typedef map<int, pair<uint256, unsigned int> > MapCheckpoints;
+ typedef list<uint256> ListBannedBlocks;
//
// What makes a good checkpoint block?
// + Contains no strange transactions
//
static MapCheckpoints mapCheckpoints =
- boost::assign::map_list_of
- ( 0, std::make_pair(hashGenesisBlock, 1360105017) )
- ( 13560, std::make_pair(uint256("0xa1591a0fcbf11f282d671581edb9f0aadcd06fee69761081e0a3245914c13729"), 1364674052) )
- ( 143990, std::make_pair(uint256("0x00000000001ff5c3940a9f73ad4a990f64955179bde0f743c76dbf0031429efc"), 1418953493) )
- ( 149000, std::make_pair(uint256("0x7a24acfcadcf43054e7f7d9f273522c0dfc5791ba4006e0273e7521a8d36c525"), 1420872125) )
- ( 160000, std::make_pair(uint256("0x000000000001cb1133043d38d077c0e93f66c8b2566779f10f182137d1e34a68"), 1425150237) )
- ( 200000, std::make_pair(uint256("0x0000000000029f8bbf66e6ea6f3e5db55009404aae0fe395a53dd33142b2bff2"), 1441127233) )
- ( 221047, std::make_pair(uint256("0xa28aef712e7aa0c285bfe29351ca21ed416689139e3063ef770fc826a8b9e9da"), 1449431646) )
- ( 243100, std::make_pair(uint256("0x000000000006522d1ebc0734cb0e6b83f5d4da0c3cbc72bd91b82016f611c4f0"), 1458215793) )
- ;
+ {
+ { 0, { hashGenesisBlock, 1360105017 } },
+ { 13560, { uint256("0xa1591a0fcbf11f282d671581edb9f0aadcd06fee69761081e0a3245914c13729"), 1364674052 } },
+ { 143990, { uint256("0x00000000001ff5c3940a9f73ad4a990f64955179bde0f743c76dbf0031429efc"), 1418953493 } },
+ { 149000, { uint256("0x7a24acfcadcf43054e7f7d9f273522c0dfc5791ba4006e0273e7521a8d36c525"), 1420872125 } },
+ { 160000, { uint256("0x000000000001cb1133043d38d077c0e93f66c8b2566779f10f182137d1e34a68"), 1425150237 } },
+ { 200000, { uint256("0x0000000000029f8bbf66e6ea6f3e5db55009404aae0fe395a53dd33142b2bff2"), 1441127233 } },
+ { 221047, { uint256("0xa28aef712e7aa0c285bfe29351ca21ed416689139e3063ef770fc826a8b9e9da"), 1449431646 } },
+ { 243100, { uint256("0x000000000006522d1ebc0734cb0e6b83f5d4da0c3cbc72bd91b82016f611c4f0"), 1458215793 } },
+ };
static ListBannedBlocks listBanned =
- boost::assign::list_of
+ {
// Invalid block #221047 with future timestamp of 2016/02/23 09:24:17 UTC
- ( uint256("0x46223e5432ceffe650d5729b4bb8479dcdf0ca1e534fa8e69382dc87b42ea94b") )
- ;
+ uint256("0x46223e5432ceffe650d5729b4bb8479dcdf0ca1e534fa8e69382dc87b42ea94b")
+ };
// TestNet has no checkpoints
static MapCheckpoints mapCheckpointsTestnet =
- boost::assign::map_list_of
- ( 0, std::make_pair(hashGenesisBlockTestNet, 1360105017) )
- ;
+ {
+ { 0, { hashGenesisBlockTestNet, 1360105017 } }
+ };
bool CheckHardened(int nHeight, const uint256& hash)
{
- MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
+ auto& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
- MapCheckpoints::const_iterator i = checkpoints.find(nHeight);
+ auto i = checkpoints.find(nHeight);
if (i == checkpoints.end()) return true;
return hash == i->second.first;
}
{
if (fTestNet) // Testnet has no banned blocks
return true;
- auto it = std::find(listBanned.begin(), listBanned.end(), nHash);
+ auto it = find(listBanned.begin(), listBanned.end(), nHash);
return it == listBanned.end();
}
int GetTotalBlocksEstimate()
{
- MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
+ auto& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
return checkpoints.rbegin()->first;
}
unsigned int GetLastCheckpointTime()
{
- MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
+ auto& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
return checkpoints.rbegin()->second.second;
}
- CBlockIndex* GetLastCheckpoint(const std::map<uint256, CBlockIndex*>& mapBlockIndex)
+ CBlockIndex* GetLastCheckpoint(const map<uint256, CBlockIndex*>& mapBlockIndex)
{
- MapCheckpoints& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
+ auto& checkpoints = (fTestNet ? mapCheckpointsTestnet : mapCheckpoints);
for(auto it = checkpoints.rbegin(); it != checkpoints.rend(); ++it)
{
if (!mapBlockIndex.count(hashCheckpoint))
return error("ValidateSyncCheckpoint: block index missing for received sync-checkpoint %s", hashCheckpoint.ToString().c_str());
- CBlockIndex* pindexSyncCheckpoint = mapBlockIndex[hashSyncCheckpoint];
- CBlockIndex* pindexCheckpointRecv = mapBlockIndex[hashCheckpoint];
+ auto pindexSyncCheckpoint = mapBlockIndex[hashSyncCheckpoint];
+ auto pindexCheckpointRecv = mapBlockIndex[hashCheckpoint];
if (pindexCheckpointRecv->nHeight <= pindexSyncCheckpoint->nHeight)
{
// Received an older checkpoint, trace back from current checkpoint
// to the same height of the received checkpoint to verify
// that current checkpoint should be a descendant block
- CBlockIndex* pindex = pindexSyncCheckpoint;
+ auto pindex = pindexSyncCheckpoint;
while (pindex->nHeight > pindexCheckpointRecv->nHeight)
if ((pindex = pindex->pprev) == NULL)
return error("ValidateSyncCheckpoint: pprev null - block index structure failure");
// Received checkpoint should be a descendant block of the current
// checkpoint. Trace back to the same height of current checkpoint
// to verify.
- CBlockIndex* pindex = pindexCheckpointRecv;
+ auto pindex = pindexCheckpointRecv;
while (pindex->nHeight > pindexSyncCheckpoint->nHeight)
if ((pindex = pindex->pprev) == NULL)
return error("ValidateSyncCheckpoint: pprev2 null - block index structure failure");
}
CTxDB txdb;
- CBlockIndex* pindexCheckpoint = mapBlockIndex[hashPendingCheckpoint];
+ auto pindexCheckpoint = mapBlockIndex[hashPendingCheckpoint];
if (!pindexCheckpoint->IsInMainChain())
{
CBlock block;
// Automatically select a suitable sync-checkpoint
uint256 AutoSelectSyncCheckpoint()
{
- const CBlockIndex *pindex = pindexBest;
+ auto pindex = pindexBest;
// Search backward for a block within max span and maturity window
while (pindex->pprev && (pindex->GetBlockTime() + CHECKPOINT_MAX_SPAN > pindexBest->GetBlockTime() || pindex->nHeight + 8 > pindexBest->nHeight))
pindex = pindex->pprev;
LOCK(cs_hashSyncCheckpoint);
// sync-checkpoint should always be accepted block
assert(mapBlockIndex.count(hashSyncCheckpoint));
- const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint];
+ auto pindexSync = mapBlockIndex[hashSyncCheckpoint];
if (nHeight > pindexSync->nHeight)
{
// trace back to same height as sync-checkpoint
- const CBlockIndex* pindex = pindexPrev;
+ auto pindex = pindexPrev;
while (pindex->nHeight > pindexSync->nHeight)
if ((pindex = pindex->pprev) == NULL)
return error("CheckSync: pprev null - block index structure failure");
bool ResetSyncCheckpoint()
{
LOCK(cs_hashSyncCheckpoint);
- const uint256& hash = mapCheckpoints.rbegin()->second.first;
+ const auto& hash = mapCheckpoints.rbegin()->second.first;
if (mapBlockIndex.count(hash) && !mapBlockIndex[hash]->IsInMainChain())
{
// checkpoint block accepted but not yet in main chain
pfrom->AskFor(CInv(MSG_BLOCK, hashPendingCheckpoint));
}
- bool SetCheckpointPrivKey(std::string strPrivKey)
+ bool SetCheckpointPrivKey(string strPrivKey)
{
// Test signing a sync-checkpoint with genesis block
CSyncCheckpoint checkpoint;
checkpoint.hashCheckpoint = !fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet;
CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
sMsg << (CUnsignedSyncCheckpoint)checkpoint;
- checkpoint.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());
+ checkpoint.vchMsg = vector<unsigned char>(sMsg.begin(), sMsg.end());
- std::vector<unsigned char> vchPrivKey = ParseHex(strPrivKey);
+ auto vchPrivKey = ParseHex(strPrivKey);
CKey key;
key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end())); // if key is not correct openssl may crash
if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig))
checkpoint.hashCheckpoint = hashCheckpoint;
CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION);
sMsg << (CUnsignedSyncCheckpoint)checkpoint;
- checkpoint.vchMsg = std::vector<unsigned char>(sMsg.begin(), sMsg.end());
+ checkpoint.vchMsg = vector<unsigned char>(sMsg.begin(), sMsg.end());
if (CSyncCheckpoint::strMasterPrivKey.empty())
return error("SendSyncCheckpoint: Checkpoint master key unavailable.");
- std::vector<unsigned char> vchPrivKey = ParseHex(CSyncCheckpoint::strMasterPrivKey);
+ auto vchPrivKey = ParseHex(CSyncCheckpoint::strMasterPrivKey);
CKey key;
key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end())); // if key is not correct openssl may crash
if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig))
// Relay checkpoint
{
LOCK(cs_vNodes);
- for (auto it = vNodes.begin(); it != vNodes.end(); ++it)
- checkpoint.RelayTo(*it);
+ for(auto pnode : vNodes)
+ checkpoint.RelayTo(pnode);
}
return true;
}
LOCK(cs_hashSyncCheckpoint);
// sync-checkpoint should always be accepted block
assert(mapBlockIndex.count(hashSyncCheckpoint));
- const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint];
+ const auto pindexSync = mapBlockIndex[hashSyncCheckpoint];
return (nBestHeight >= pindexSync->nHeight + nCoinbaseMaturity ||
pindexSync->GetBlockTime() + nStakeMinAge < GetAdjustedTime());
}
}
// ppcoin: sync-checkpoint master key
-const std::string CSyncCheckpoint::strMasterPubKey = "04a51b735f816de4ec3f891d5b38bbc91e1f7245c7c08d17990760b86b4d8fc3910a850ffecf73bfa8886f01739a0c4c4322201282d07b6e48ce931cc92af94850";
+const string CSyncCheckpoint::strMasterPubKey = "04a51b735f816de4ec3f891d5b38bbc91e1f7245c7c08d17990760b86b4d8fc3910a850ffecf73bfa8886f01739a0c4c4322201282d07b6e48ce931cc92af94850";
-std::string CSyncCheckpoint::strMasterPrivKey = "";
+string CSyncCheckpoint::strMasterPrivKey = "";
// ppcoin: verify signature of sync-checkpoint message
bool CSyncCheckpoint::CheckSignature()
#include "util.h"
#include "main.h"
#include "ui_interface.h"
+
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
-#include <boost/assign/list_of.hpp>
-
#include "kernel.h"
#include "kernel_worker.h"
#include "txdb.h"
-extern unsigned int nStakeMaxAge;
-extern unsigned int nStakeTargetSpacing;
+extern uint32_t nStakeMaxAge;
+extern uint32_t nStakeTargetSpacing;
using namespace std;
-
// Protocol switch time for fixed kernel modifier interval
-unsigned int nModifierSwitchTime = 1413763200; // Mon, 20 Oct 2014 00:00:00 GMT
-unsigned int nModifierTestSwitchTime = 1397520000; // Tue, 15 Apr 2014 00:00:00 GMT
+uint32_t nModifierSwitchTime = 1413763200; // Mon, 20 Oct 2014 00:00:00 GMT
+uint32_t nModifierTestSwitchTime = 1397520000; // Tue, 15 Apr 2014 00:00:00 GMT
// Note: user must upgrade before the protocol switch deadline, otherwise it's required to
// re-download the blockchain. The timestamp of upgrade is recorded in the blockchain
// database.
-unsigned int nModifierUpgradeTime = 0;
-
-typedef std::map<int, unsigned int> MapModifierCheckpoints;
+uint32_t nModifierUpgradeTime = 0;
// Hard checkpoints of stake modifiers to ensure they are deterministic
-static std::map<int, unsigned int> mapStakeModifierCheckpoints =
- boost::assign::map_list_of
- ( 0, 0x0e00670bu )
- ( 12661, 0x5d84115du )
- (143990, 0x9c592c78u )
- (149000, 0x48f2bdc4u )
- (160000, 0x789df0f0u )
- (200000, 0x01ec1503u )
- (221047, 0x0b39ef50u )
- (243100, 0xe928d83au )
- ;
+static map<int, uint32_t> mapStakeModifierCheckpoints =
+{
+ { 0, 0x0e00670bu },
+ { 12661, 0x5d84115du },
+ { 143990, 0x9c592c78u },
+ { 149000, 0x48f2bdc4u },
+ { 160000, 0x789df0f0u },
+ { 200000, 0x01ec1503u },
+ { 221047, 0x0b39ef50u },
+ { 243100, 0xe928d83au },
+};
// Hard checkpoints of stake modifiers to ensure they are deterministic (testNet)
-static std::map<int, unsigned int> mapStakeModifierCheckpointsTestNet =
- boost::assign::map_list_of
- ( 0, 0x0e00670bu )
- ;
+static map<int, uint32_t> mapStakeModifierCheckpointsTestNet =
+{
+ { 0, 0x0e00670bu }
+};
// Pregenerated entropy bits table (from genesis to #9689)
//
{
if (!mapBlockIndex.count(item.second))
return error("SelectBlockFromCandidates: failed to find block index for candidate block %s", item.second.ToString().c_str());
- const CBlockIndex* pindex = mapBlockIndex[item.second];
+ auto pindex = mapBlockIndex[item.second];
if (fSelected && pindex->GetBlockTime() > nSelectionIntervalStop)
break;
if (mapSelectedBlocks.count(pindex->GetBlockHash()) > 0)
continue;
// compute the selection hash by hashing its proof-hash and the
// previous proof-of-stake modifier
- uint256 hashProof = pindex->IsProofOfStake()? pindex->hashProofOfStake : pindex->GetBlockHash();
+ auto hashProof = pindex->IsProofOfStake()? pindex->hashProofOfStake : pindex->GetBlockHash();
CDataStream ss(SER_GETHASH, 0);
ss << hashProof << nStakeModifierPrev;
- uint256 hashSelection = Hash(ss.begin(), ss.end());
+ auto hashSelection = Hash(ss.begin(), ss.end());
// the selection hash is divided by 2**32 so that proof-of-stake block
// is always favored over proof-of-work block. this is to preserve
// the energy efficiency property
{
nStakeModifier = 0;
fGeneratedStakeModifier = false;
- const CBlockIndex* pindexPrev = pindexCurrent->pprev;
+ auto pindexPrev = pindexCurrent->pprev;
if (!pindexPrev)
{
fGeneratedStakeModifier = true;
// Sort candidate blocks by timestamp
vector<pair<int64_t, uint256> > vSortedByTimestamp;
vSortedByTimestamp.reserve(64 * nModifierInterval / nStakeTargetSpacing);
- int64_t nSelectionInterval = GetStakeModifierSelectionInterval();
- int64_t nSelectionIntervalStart = (pindexPrev->GetBlockTime() / nModifierInterval) * nModifierInterval - nSelectionInterval;
- const CBlockIndex* pindex = pindexPrev;
+ auto nSelectionInterval = GetStakeModifierSelectionInterval();
+ auto nSelectionIntervalStart = (pindexPrev->GetBlockTime() / nModifierInterval) * nModifierInterval - nSelectionInterval;
+ const auto *pindex = pindexPrev;
while (pindex && pindex->GetBlockTime() >= nSelectionIntervalStart)
{
vSortedByTimestamp.push_back(make_pair(pindex->GetBlockTime(), pindex->GetBlockHash()));
// Select 64 blocks from candidate blocks to generate stake modifier
uint64_t nStakeModifierNew = 0;
- int64_t nSelectionIntervalStop = nSelectionIntervalStart;
+ auto nSelectionIntervalStop = nSelectionIntervalStart;
map<uint256, const CBlockIndex*> mapSelectedBlocks;
for (int nRound=0; nRound<min(64, (int)vSortedByTimestamp.size()); nRound++)
{
nStakeModifier = 0;
if (!mapBlockIndex.count(hashBlockFrom))
return error("GetKernelStakeModifier() : block not indexed");
- const CBlockIndex* pindexFrom = mapBlockIndex[hashBlockFrom];
+ auto pindexFrom = mapBlockIndex[hashBlockFrom];
nStakeModifierHeight = pindexFrom->nHeight;
nStakeModifierTime = pindexFrom->GetBlockTime();
- int64_t nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval();
- const CBlockIndex* pindex = pindexFrom;
+ auto nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval();
+ auto pindex = pindexFrom;
// loop to find the stake modifier later by a selection interval
while (nStakeModifierTime < pindexFrom->GetBlockTime() + nStakeModifierSelectionInterval)
{
CBigNum bnTargetPerCoinDay;
bnTargetPerCoinDay.SetCompact(nBits);
- int64_t nValueIn = txPrev.vout[prevout.n].nValue;
-
- uint256 hashBlockFrom = blockFrom.GetHash();
-
- CBigNum bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)txPrev.nTime, (int64_t)nTimeTx) / COIN / nOneDay;
+ auto nValueIn = txPrev.vout[prevout.n].nValue;
+ auto hashBlockFrom = blockFrom.GetHash();
+ auto bnCoinDayWeight = CBigNum(nValueIn) * GetWeight((int64_t)txPrev.nTime, (int64_t)nTimeTx) / COIN / nOneDay;
targetProofOfStake = (bnCoinDayWeight * bnTargetPerCoinDay).getuint256();
// Calculate hash
}
// Scan given kernel for solution
-bool ScanKernelForward(unsigned char *kernel, uint32_t nBits, uint32_t nInputTxTime, int64_t nValueIn, std::pair<uint32_t, uint32_t> &SearchInterval, std::vector<std::pair<uint256, uint32_t> > &solutions)
+bool ScanKernelForward(unsigned char *kernel, uint32_t nBits, uint32_t nInputTxTime, int64_t nValueIn, pair<uint32_t, uint32_t> &SearchInterval, vector<pair<uint256, uint32_t> > &solutions)
{
// TODO: custom threads amount
for(size_t i = 0; i < nThreads; i++)
{
- std::vector<std::pair<uint256, uint32_t> > ws = workers[i].GetSolutions();
+ vector<pair<uint256, uint32_t> > ws = workers[i].GetSolutions();
solutions.insert(solutions.end(), ws.begin(), ws.end());
}
return error("CheckProofOfStake() : called on non-coinstake %s", tx.GetHash().ToString().c_str());
// Kernel (input 0) must match the stake hash target per coin age (nBits)
- const CTxIn& txin = tx.vin[0];
+ const auto& txin = tx.vin[0];
// First try finding the previous transaction in database
CTxDB txdb("r");
if (pindex->pprev)
ss << pindex->pprev->nStakeModifierChecksum;
ss << pindex->nFlags << pindex->hashProofOfStake << pindex->nStakeModifier;
- uint256 hashChecksum = Hash(ss.begin(), ss.end());
+ auto hashChecksum = Hash(ss.begin(), ss.end());
hashChecksum >>= (256 - 32);
return static_cast<uint32_t>(hashChecksum.Get64());
}
// Check stake modifier hard checkpoints
bool CheckStakeModifierCheckpoints(int nHeight, uint32_t nStakeModifierChecksum)
{
- MapModifierCheckpoints& checkpoints = (fTestNet ? mapStakeModifierCheckpointsTestNet : mapStakeModifierCheckpoints);
+ auto& checkpoints = (fTestNet ? mapStakeModifierCheckpointsTestNet : mapStakeModifierCheckpoints);
if (checkpoints.count(nHeight))
return nStakeModifierChecksum == checkpoints[nHeight];
#include "wallet.h"
// ChainDB upgrade time
-extern unsigned int nModifierUpgradeTime;
+extern uint32_t nModifierUpgradeTime;
// MODIFIER_INTERVAL: time to elapse before new modifier is computed
-extern unsigned int nModifierInterval;
+extern uint32_t nModifierInterval;
// MODIFIER_INTERVAL_RATIO:
// ratio of group interval length between the last group and the first group
static const int MODIFIER_INTERVAL_RATIO = 3;
// Whether the given block is subject to new modifier protocol
-bool IsFixedModifierInterval(unsigned int nTimeBlock);
+bool IsFixedModifierInterval(uint32_t nTimeBlock);
// Compute the hash modifier for proof-of-stake
bool ComputeNextStakeModifier(const CBlockIndex* pindexCurrent, uint64_t& nStakeModifier, bool& fGeneratedStakeModifier);
// Check whether stake kernel meets hash target
// Sets hashProofOfStake on success return
-bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, uint32_t nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, uint32_t nTimeTx, uint256& hashProofOfStake, uint256& targetProofOfStake, bool fPrintProofOfStake=false);
+bool CheckStakeKernelHash(uint32_t nBits, const CBlock& blockFrom, uint32_t nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, uint32_t nTimeTx, uint256& hashProofOfStake, uint256& targetProofOfStake, bool fPrintProofOfStake=false);
// Scan given kernel for solutions
bool ScanKernelForward(unsigned char *kernel, uint32_t nBits, uint32_t nInputTxTime, int64_t nValueIn, std::pair<uint32_t, uint32_t> &SearchInterval, std::vector<std::pair<uint256, uint32_t> > &solutions);
// Check kernel hash target and coinstake signature
// Sets hashProofOfStake on success return
-bool CheckProofOfStake(const CTransaction& tx, unsigned int nBits, uint256& hashProofOfStake, uint256& targetProofOfStake);
+bool CheckProofOfStake(const CTransaction& tx, uint32_t nBits, uint256& hashProofOfStake, uint256& targetProofOfStake);
// Get stake modifier checksum
uint32_t GetStakeModifierChecksum(const CBlockIndex* pindex);
return std::min(nIntervalEnd - nIntervalBeginning - nStakeMinAge, (int64_t)nStakeMaxAge);
}
-#endif // PPCOIN_KERNEL_H
\ No newline at end of file
+#endif // PPCOIN_KERNEL_H
// Sha256 result buffer
uint32_t hashProofOfStake[8];
- uint256 *pnHashProofOfStake = (uint256 *)&hashProofOfStake;
+ auto pnHashProofOfStake = (uint256 *)&hashProofOfStake;
// Search forward in time from the given timestamp
// Stopping search in case of shutting down
if (hashProofOfStake[7] > nMaxTarget32)
continue;
- CBigNum bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / COIN / nOneDay;
- CBigNum bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay;
+ auto bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / COIN / nOneDay;
+ auto bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay;
if (bnTargetProofOfStake >= CBigNum(*pnHashProofOfStake))
- solutions.push_back(std::pair<uint256,uint32_t>(*pnHashProofOfStake, nTimeTx));
+ solutions.push_back(make_pair(*pnHashProofOfStake, nTimeTx));
}
}
// Search backward in time from the given timestamp
// Stopping search in case of shutting down
- for (uint32_t nTimeTx=SearchInterval.first; nTimeTx>SearchInterval.second && !fShutdown; nTimeTx--)
+ for (auto nTimeTx=SearchInterval.first; nTimeTx>SearchInterval.second && !fShutdown; nTimeTx--)
{
// Complete first hashing iteration
uint256 hash1;
if (hashProofOfStake > nMaxTarget)
continue;
- CBigNum bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / COIN / nOneDay;
- CBigNum bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay;
+ auto bnCoinDayWeight = bnValueIn * GetWeight((int64_t)nInputTxTime, (int64_t)nTimeTx) / COIN / nOneDay;
+ auto bnTargetProofOfStake = bnCoinDayWeight * bnTargetPerCoinDay;
if (bnTargetProofOfStake >= CBigNum(hashProofOfStake))
{