Merge pull request #29 from 8bitcoder/master

Set post hard fork consensus
This commit is contained in:
8bitcoder
2016-08-21 13:14:37 +02:00
committed by GitHub
4 changed files with 8 additions and 54 deletions
-4
View File
@@ -69,8 +69,6 @@ public:
consensus.nBlockAlgoNormalisedWorkDecayStart2 = 932000; // block where weight decay starts
consensus.nGeoAvgWork_Start = 1400000;
consensus.nFork1MinBlock = 1764000; // minimum block height where fork 1 takes effect (algo switch, seq algo count change)
consensus.nMajorityEnableAlgoSwitch1 = 750;
consensus.nAlgoSwitch1EnableWindow = 2000;
/**
* The message start string is designed to be unlikely to occur in normal data.
@@ -214,8 +212,6 @@ public:
consensus.nBlockAlgoNormalisedWorkDecayStart2 = 0; // block where weight decay starts
consensus.nGeoAvgWork_Start = 150;
consensus.nFork1MinBlock = 300;
consensus.nMajorityEnableAlgoSwitch1 = 60;
consensus.nAlgoSwitch1EnableWindow = 200;
pchMessageStart[0] = 0x01;
pchMessageStart[1] = 0xf5;
-2
View File
@@ -45,8 +45,6 @@ struct Params {
int64_t nBlockAlgoNormalisedWorkDecayStart2;
int64_t nGeoAvgWork_Start;
int64_t nFork1MinBlock;
int nMajorityEnableAlgoSwitch1;
int nAlgoSwitch1EnableWindow;
int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacingV1; }
+3 -28
View File
@@ -84,7 +84,6 @@ void EraseOrphansFor(NodeId peer);
* in the last Consensus::Params::nMajorityWindow blocks, starting at pstart and going backwards.
*/
static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned nRequired, const Consensus::Params& consensusParams);
static bool IsAlgoSwitch1Active(const CBlockIndex* pstart, const Consensus::Params& consensusParams);
static void CheckBlockIndex();
/** Constant stuff for coinbase transactions we create: */
@@ -2948,18 +2947,8 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
REJECT_INVALID, "time-too-old");
// Check for algo switch 1
// Active when:
// previous YESCRYPT block was mined or;
// mining majority and fork height reached
bool bAlgoSwitch1 = false;
if (nHeight >= consensusParams.nFork1MinBlock)
{
bAlgoSwitch1 = IsAlgoSwitch1Active(pindexPrev, consensusParams);
if (!bAlgoSwitch1)
bAlgoSwitch1 =
(block.nVersion > 3) &&
IsSuperMajority(4, pindexPrev, consensusParams.nMajorityEnableAlgoSwitch1, consensusParams);
}
// Active when fork block reached
bool bAlgoSwitch1 = (nHeight >= consensusParams.nFork1MinBlock);
if (bAlgoSwitch1)
{
if (algo == ALGO_QUBIT)
@@ -3076,9 +3065,7 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
// Maximum sequence count allowed
int nMaxSeqCount;
if ( (nHeight > chainparams.GetConsensus().nFork1MinBlock) &&
(block.nVersion > 3) &&
IsSuperMajority(4, pindexPrev, chainparams.GetConsensus().nMajorityEnableAlgoSwitch1, chainparams.GetConsensus()) )
if (nHeight > chainparams.GetConsensus().nFork1MinBlock)
nMaxSeqCount = chainparams.GetConsensus().nBlockSequentialAlgoMaxCount3;
else
if (nHeight > chainparams.GetConsensus().nBlockSequentialAlgoRuleStart2)
@@ -3193,18 +3180,6 @@ static bool IsSuperMajority(int minVersion, const CBlockIndex* pstart, unsigned
return (nFound >= nRequired);
}
static bool IsAlgoSwitch1Active(const CBlockIndex* pstart, const Consensus::Params& consensusParams)
{
bool algoFound = false;
for (int i = 0; i < consensusParams.nAlgoSwitch1EnableWindow && !algoFound && pstart != NULL; i++)
{
if (pstart->GetAlgo() == ALGO_YESCRYPT)
algoFound = true;
pstart = pstart->pprev;
}
return (algoFound);
}
bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, bool fForceProcessing, CDiskBlockPos *dbp)
{
// Preliminary checks
+5 -20
View File
@@ -545,21 +545,6 @@ Object SoftForkDesc(const std::string &name, int version, CBlockIndex* pindex, c
return rv;
}
Object AlgoSwitch1ForkDesc(const std::string &name, int version, CBlockIndex* pindex, const Consensus::Params& consensusParams)
{
Object rv;
rv.push_back(Pair("id", name));
rv.push_back(Pair("version", version));
Object bh;
int nHeight = (int)chainActive.Height();
bh.push_back(Pair("status", nHeight >= consensusParams.nFork1MinBlock));
bh.push_back(Pair("height", nHeight));
bh.push_back(Pair("height-active", consensusParams.nFork1MinBlock));
rv.push_back(Pair("enforce-condition-blockheight", bh));
rv.push_back(Pair("enforce-condition-majority", SoftForkMajorityDesc(version, pindex, consensusParams.nMajorityEnableAlgoSwitch1, consensusParams)));
return rv;
}
Value getblockchaininfo(const Array& params, bool fHelp)
{
if (fHelp || params.size() != 0)
@@ -617,13 +602,13 @@ Value getblockchaininfo(const Array& params, bool fHelp)
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
obj.push_back(Pair("pruned", fPruneMode));
const Consensus::Params& consensusParams = Params().GetConsensus();
CBlockIndex* tip = chainActive.Tip();
//const Consensus::Params& consensusParams = Params().GetConsensus();
//CBlockIndex* tip = chainActive.Tip();
Array softforks;
// softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
softforks.push_back(AlgoSwitch1ForkDesc("algoswitch1", 4, tip, consensusParams));
// softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
// softforks.push_back(SoftForkDesc("bip65", 4, tip, consensusParams));
// softforks.push_back(AlgoSwitch1ForkDesc("algoswitch1", 4, tip, consensusParams));
obj.push_back(Pair("softforks", softforks));
if (fPruneMode)