Skip to content

Commit

Permalink
Merge pull request #2 from barrystyle/0.14-regentestnet
Browse files Browse the repository at this point in the history
0.14 regentestnet
  • Loading branch information
barrystyle authored Jul 20, 2019
2 parents 6a657df + 0ec579a commit 479b112
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 49 deletions.
18 changes: 3 additions & 15 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,21 +485,9 @@ class CTestNetParams : public CChainParams {
nDefaultPort = 29999;
nPruneAfterHeight = 1000;

/////////////////////////////////////////////////////////////////////////
uint32_t nTime = 1563050000;
uint32_t nNonce = 0;
while (UintToArith256(genesis.GetHash()) >
UintToArith256(consensus.powLimit))
{
nNonce++;
genesis = CreateGenesisBlock(nTime, nNonce, 0x1f00ffff, 1, 0 * COIN);
}
genesis = CreateGenesisBlock(nTime, nNonce, 0x1f00ffff, 1, 0 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
/////////////////////////////////////////////////////////////////////////

genesis = CreateGenesisBlock(1563589000, 62255, 0x1f00ffff, 1, 0 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
// assert(consensus.hashGenesisBlock == uint256S("0x0000071f25514da6d65c4fa2187ef8ee1f6b6a68b7761af91ecfb28dc85d3e8a"));
assert(consensus.hashGenesisBlock == uint256S("0x0000b67f0d64e977df72e86de5ef38e46b03d163790ed9a12e43240915be7197"));

vFixedSeeds.clear();
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
Expand Down Expand Up @@ -549,7 +537,7 @@ class CTestNetParams : public CChainParams {
};

chainTxData = ChainTxData{
nTime, // * UNIX timestamp of last known number of transactions
1563589000, // * UNIX timestamp of last known number of transactions
0, // * total number of transactions between genesis and that timestamp
// (the tx=... number in the SetBestChain debug.log lines)
0.0 // * estimated number of transactions per second after that timestamp
Expand Down
2 changes: 1 addition & 1 deletion src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ unsigned int getIntervalVersion(bool fTestNet)

// Hard checkpoints of stake modifiers to ensure they are deterministic
static std::map<int, unsigned int> mapStakeModifierCheckpoints =
boost::assign::map_list_of(0, 0xfd11f4e7);
boost::assign::map_list_of(0, 0x0e00670b);

// Get time weight
int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd)
Expand Down
6 changes: 3 additions & 3 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ boost::filesystem::path GetDefaultDataDir()
// Unix: ~/.dashcore
#ifdef WIN32
// Windows
return GetSpecialFolderPath(CSIDL_APPDATA) / "pactestneta";
return GetSpecialFolderPath(CSIDL_APPDATA) / "PACGlobal";
#else
fs::path pathRet;
char* pszHome = getenv("HOME");
Expand All @@ -581,10 +581,10 @@ boost::filesystem::path GetDefaultDataDir()
pathRet = fs::path(pszHome);
#ifdef MAC_OSX
// Mac
return pathRet / "Library/Application Support/pactestneta";
return pathRet / "Library/Application Support/PACGlobal";
#else
// Unix
return pathRet / ".pactestneta";
return pathRet / ".PACGlobal";
#endif
#endif
}
Expand Down
54 changes: 26 additions & 28 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3165,54 +3165,50 @@ bool ResetBlockFailureFlags(CBlockIndex *pindex) {
return true;
}

static void AcceptProofOfStakeBlock(const CBlock &block, CBlockIndex *pindexNew)
bool AcceptProofOfStakeBlock(const CBlock &block, CBlockIndex *pindex)
{
if(!pindexNew)
return;
if (!pindex)
return false;

if (block.IsProofOfStake()) {
pindexNew->SetProofOfStake();
pindexNew->prevoutStake = block.vtx[1]->vin[0].prevout;
pindexNew->nStakeTime = block.nTime;
pindex->SetProofOfStake();
pindex->prevoutStake = block.vtx[1]->vin[0].prevout;
pindex->nStakeTime = block.nTime;
} else {
pindexNew->prevoutStake.SetNull();
pindexNew->nStakeTime = 0;
pindex->prevoutStake.SetNull();
pindex->nStakeTime = 0;
}

//update previous block pointer
// pindexNew->pprev->pnext = pindexNew;

// ppcoin: compute chain trust score
pindexNew->bnChainTrust = (pindexNew->pprev ? pindexNew->pprev->bnChainTrust : ArithToUint256(0 + pindexNew->GetBlockTrust()));
pindex->bnChainTrust = (pindex->pprev ? pindex->pprev->bnChainTrust : ArithToUint256(0 + pindex->GetBlockTrust()));

// ppcoin: compute stake entropy bit for stake modifier
if (!pindexNew->SetStakeEntropyBit(pindexNew->GetStakeEntropyBit()))
if (!pindex->SetStakeEntropyBit(pindex->GetStakeEntropyBit()))
LogPrintf("AcceptProofOfStakeBlock() : SetStakeEntropyBit() failed \n");

uint256 hash = block.GetHash();

// ppcoin: record proof-of-stake hash value
if (pindexNew->IsProofOfStake()) {
if (pindex->IsProofOfStake()) {
uint256 hash = block.GetHash();
if (!mapProofOfStake.count(hash))
LogPrintf("AcceptProofOfStakeBlock() : hashProofOfStake not found in map \n");
pindexNew->hashProofOfStake = mapProofOfStake[hash];
pindex->hashProofOfStake = mapProofOfStake[hash];
}

// ppcoin: compute stake modifier
uint64_t nStakeModifier = 0;
bool fGeneratedStakeModifier = false;
if (!ComputeNextStakeModifier(pindexNew, nStakeModifier, fGeneratedStakeModifier))
if (!ComputeNextStakeModifier(pindex, nStakeModifier, fGeneratedStakeModifier))
LogPrintf("AcceptProofOfStakeBlock() : ComputeNextStakeModifier() failed \n");
pindexNew->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier);
pindexNew->nStakeModifierChecksum = GetStakeModifierChecksum(pindexNew);
if (!CheckStakeModifierCheckpoints(pindexNew->nHeight, pindexNew->nStakeModifierChecksum)) {
LogPrintf("AcceptProofOfStakeBlock() : Rejected by stake modifier checkpoint height=%d, modifier=%s \n", pindexNew->nHeight, std::to_string(nStakeModifier));
LogPrintf("pindexNew->nStakeModifierChecksum = %08x\n", pindexNew->nStakeModifierChecksum);
} else {
LogPrintf("AcceptProofOfStakeBlock() : Accepted stake modifier - checksum %08x\n", pindexNew->nStakeModifierChecksum);
pindex->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier);
pindex->nStakeModifierChecksum = GetStakeModifierChecksum(pindex);
if (!CheckStakeModifierCheckpoints(pindex->nHeight, pindex->nStakeModifierChecksum)) {
LogPrintf("AcceptProofOfStakeBlock() : Rejected by stake modifier checkpoint height=%d, modifier=0x%016llx, checksum=0x%08x\n",
pindex->nHeight, nStakeModifier, pindex->nStakeModifierChecksum);
return false;
}

setDirtyBlockIndex.insert(pindexNew);
setDirtyBlockIndex.insert(pindex);
return true;
}

CBlockIndex* AddToBlockIndex(const CBlockHeader& block, enum BlockStatus nStatus = BLOCK_VALID_TREE)
Expand Down Expand Up @@ -3794,7 +3790,8 @@ static bool AcceptBlock(const std::shared_ptr<const CBlock>& pblock, CValidation
return error("%s: %s", __func__, FormatStateMessage(state));
}

AcceptProofOfStakeBlock(block, pindex);
if (!AcceptProofOfStakeBlock(block, pindex))
return false;

// Header is valid/has work, merkle tree is good...RELAY NOW
// (but if it does not build on our best tip, let the SendMessages loop relay it)
Expand Down Expand Up @@ -4427,7 +4424,8 @@ static bool AddGenesisBlock(const CChainParams& chainparams, const CBlock& block
if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart()))
return error("%s: writing genesis block to disk failed", __func__);
CBlockIndex *pindex = AddToBlockIndex(block);
AcceptProofOfStakeBlock(block, pindex);
if (!AcceptProofOfStakeBlock(block, pindex))
return error("%s: genesis block not accepted", __func__);
if (!ReceivedBlockTransactions(block, state, pindex, blockPos))
return error("%s: genesis block not accepted", __func__);
return true;
Expand Down
4 changes: 2 additions & 2 deletions src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/


static const int PROTOCOL_VERSION = 70215;
static const int PROTOCOL_VERSION = 70216;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
Expand All @@ -20,7 +20,7 @@ static const int INIT_PROTO_VERSION = 209;
static const int GETHEADERS_VERSION = 70077;

//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION = 70213;
static const int MIN_PEER_PROTO_VERSION = 70216;

//! nTime field added to CAddress, starting with this version;
//! if possible, avoid requesting addresses nodes older than this
Expand Down

0 comments on commit 479b112

Please sign in to comment.