Something like this should do the trick (disable the broken one-week crap, switch to solidcoin algo after block 14639).
diff -Nur I0coinClientv1.0-linux-stable-orig/src/main.cpp I0coinClientv1.0-linux-stable-dev/src/main.cpp
--- I0coinClientv1.0-linux-stable-orig/src/main.cpp 2011-08-18 23:15:50.000000000 +0200
+++ I0coinClientv1.0-linux-stable-dev/src/main.cpp 2011-08-25 08:23:52.143725519 +0200
@@ -644,7 +644,7 @@
return nSubsidy + nFees;
}
-unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast)
+unsigned int static GetNextWorkRequired_OLD(const CBlockIndex* pindexLast)
{
const int64 nTargetTimespan = 7 * 24 * 60 * 60; // two weeks
const int64 nTargetSpacing = 5 * 60;
@@ -659,6 +659,7 @@
// Only change once per interval
if ( nRemaining != 0)
{
+/* HORRIBLY BROKEN, *NEVER* use time() in here
const CBlockIndex* pindexFirst = pindexLast;
for (int i = 0; pindexFirst && i < nRemaining-1; i++)
pindexFirst = pindexFirst->pprev;
@@ -666,6 +667,7 @@
int64 rema = GetAdjustedTime() - pindexFirst->GetBlockTime();
if(rema < nTargetTimespan)
+*/
return pindexLast->nBits;
}
@@ -691,6 +693,71 @@
if (bnNew > bnProofOfWorkLimit)
bnNew = bnProofOfWorkLimit;
+
+ /// debug print
+ printf("GetNextWorkRequired RETARGET\n");
+ printf("nTargetTimespan = %"PRI64d" nActualTimespan = %"PRI64d"\n", nTargetTimespan, nActualTimespan);
+ printf("Before: %08x %s\n", pindexLast->nBits, CBigNum().SetCompact(pindexLast->nBits).getuint256().ToString().c_str());
+ printf("After: %08x %s\n", bnNew.GetCompact(), bnNew.getuint256().ToString().c_str());
+
+ return bnNew.GetCompact();
+}
+
+//blatantly stolen from SolidCoin
+unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast)
+{
+ const int64 nTargetTimespan = 12 * 60 * 60; // 12 hours
+ const int64 nTargetSpacing = 3 * 60; //3 minute blocks
+ const int64 nInterval = nTargetTimespan / nTargetSpacing;
+
+ // Genesis block
+ if (pindexLast == NULL)
+ return bnProofOfWorkLimit.GetCompact();
+
+//okay, maybe not this line
+ if ((pindexLast->nHeight+1) < 14640)
+ return GetNextWorkRequired_OLD(pindexLast);
+
+ // Only change once per interval
+ if ((pindexLast->nHeight+1) % nInterval != 0)
+ return pindexLast->nBits;
+
+ // Go back by what we want to be 14 days worth of blocks
+ const CBlockIndex* pindexFirst = pindexLast;
+ for (int i = 0; pindexFirst && i < nInterval-1; i++)
+ pindexFirst = pindexFirst->pprev;
+ assert(pindexFirst);
+
+ // Limit adjustment step
+ int64 nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime();
+ int64 nTwoPercent = nTargetTimespan/50;
+ //printf(" nActualTimespan = %"PRI64d" before bounds\n", nActualTimespan);
+
+ if (nActualTimespan < nTargetTimespan) //is time taken for a block less than 3minutes?
+ {
+ //limit increase to a much lower amount than dictates to get past the pump-n-dump mining phase
+ //due to retargets being done more often it also needs to be lowered significantly from the 4x increase
+ if(nActualTimespan<(nTwoPercent*16)) //less than a minute?
+ nActualTimespan=(nTwoPercent*45); //pretend it was only 10% faster than desired
+ else if(nActualTimespan<(nTwoPercent*32)) //less than 2 minutes?
+ nActualTimespan=(nTwoPercent*47); //pretend it was only 6% faster than desired
+ else
+ nActualTimespan=(nTwoPercent*49); //pretend it was only 2% faster than desired
+
+ //int64 nTime=nTargetTimespan-nActualTimespan;
+ //nActualTimespan = nTargetTimespan/2;
+ }
+ else if (nActualTimespan > nTargetTimespan*4) nActualTimespan = nTargetTimespan*4;
+
+ // Retarget
+ CBigNum bnNew;
+ bnNew.SetCompact(pindexLast->nBits);
+ bnNew *= nActualTimespan;
+ bnNew /= nTargetTimespan;
+
+
+ if (bnNew > bnProofOfWorkLimit)
+ bnNew = bnProofOfWorkLimit;
/// debug print
printf("GetNextWorkRequired RETARGET\n");