Skip to content

Commit

Permalink
added time warp fix courtesy of ArtForz and added it to namecoin.conf…
Browse files Browse the repository at this point in the history
… as an example
  • Loading branch information
sacarlson committed Sep 30, 2011
1 parent 20acce3 commit 98deadb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/bitcoin.conf.namecoin
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,6 @@ AuxPowStartBlock=19200

# this chain ID number as with bitcoin chainid=0 namecoin chainid=1, at this point I'm not sure if we should set to 1 or 2 or?
OurChainID=1

#this is the block number that activates time warp fix by ArtForz in GetNextWorkRequired() function, in namecoin it starts at 19200.
FullRetargetStartBlock=19200
8 changes: 7 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -789,9 +789,15 @@ unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast)
return pindexLast->nBits;
}

// Go back the full period unless it's the first retarget after genesis. Code courtesy of ArtForz

int nBlocksBack = nInterval-1;
if(pindexLast->nHeight >= GetArgIntxx(INT_MAX,"-FullRetargetStartBlock") && ((pindexLast->nHeight+1) > nInterval))
nBlocksBack = nInterval;

// 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++)
for (int i = 0; pindexFirst && i < nBlocksBack; i++)
pindexFirst = pindexFirst->pprev;
assert(pindexFirst);

Expand Down

0 comments on commit 98deadb

Please sign in to comment.