Merge pull request #29 from myriadcoin/master

Post fork changes
This commit is contained in:
8bitcoder
2016-08-30 11:38:43 +02:00
committed by GitHub
5 changed files with 13 additions and 58 deletions
+4 -7
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.
@@ -164,9 +162,10 @@ public:
(1336174, uint256S("0x00000000000001eafb1051fda69eb842577a0e48e4f0682bd7f33677373d0807"))
(1402167, uint256S("0x8215cd9feb2db9bf74514361a9d4b4440f054101079df8bb6bf629065db3ab29"))
(1449500, uint256S("0xef19939e314f239999b9959ac908b20a43b165719d1c35dcfe38ba2566d20765"))
(1681927, uint256S("0x9be88de17bccfa3ceb43d158652189af2c3038460dcf91732320a73557fe6a2e")),
1465113607, // * UNIX timestamp of last checkpoint block
4409414, // * total number of transactions between genesis and last checkpoint
(1681927, uint256S("0x9be88de17bccfa3ceb43d158652189af2c3038460dcf91732320a73557fe6a2e"))
(1764003, uint256S("0xf969487c0ba2426bf767a5cb83c6bb7f3f9a19cccdcfc50cf5db0b39032aae55")),
1471576582, // * UNIX timestamp of last checkpoint block
4521232, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
2880 // * estimated number of transactions per day after checkpoint
};
@@ -213,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)
+1 -1
View File
@@ -24,7 +24,7 @@ static const int AUX_POW_SHA_SCRYPT_VERSION = 70003;
static const int QUBIT_TO_YESCRYPT_VERSION = 70004;
//! disconnect from peers older than this proto version
static const int MIN_PEER_PROTO_VERSION = AUX_POW_SHA_SCRYPT_VERSION;
static const int MIN_PEER_PROTO_VERSION = QUBIT_TO_YESCRYPT_VERSION;
//! nTime field added to CAddress, starting with this version;
//! if possible, avoid requesting addresses nodes older than this