Author

Topic: Need Help Updating Current Code - Kind Developers Give me a Hand (Read 408 times)

full member
Activity: 560
Merit: 105
Any kind developer that could give a hand? I am updating a client for a coin I think I got it right. But I want any experienced developer help me on this. I also added some checkpoints for the new wallet.

I want to change the retarget the difficulty from 960 blocks (1 day) to 40 blocks (1 hours) of a coin.

Code:
static int64 nTargetTimespan = 1 * 24 * 60 * 60; // 1 day
static int64 nTargetSpacing = 90; // 1.5 minute blocks
static int64 nInterval = nTargetTimespan / nTargetSpacing;
static int64 nReTargetHistoryFact = 4; // look at 4 times the retarget interval into block history

Code:
unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlock *pblock)
{
    unsigned int nProofOfWorkLimit = bnProofOfWorkLimit.GetCompact();

    // Genesis block
    if (pindexLast == NULL)
        return nProofOfWorkLimit;

    // From block 28000 reassess the difficulty every 40 blocks
// Reduce Retarget factor to 2
    if(pindexLast->nHeight >= 28000)
    {
        nTargetTimespan = 60 * 60; // 1 hours
        nTargetSpacing = 1.5 * 60; // 1.5 minutes
        nInterval = nTargetTimespan / nTargetSpacing;
nReTargetHistoryFact = 2;
    }
else
{
nTargetTimespan = 1 * 24 * 60 * 60; // 1 day
nTargetSpacing = 1.5 * 60; // 1.5 minutes
nInterval = nTargetTimespan / nTargetSpacing;
nReTargetHistoryFact = 4;
}

What do you think? This code will trigger a change in difficulty upon block 28000? Or do I need to do more stuff?

I appreciate any help.

Best wishes,

itos
Jump to: