Permalink
Browse files

Add support for configurable minimum time and block this starts at

To test, try something like:
./catcoind -forkminimum=10000 -minblocktime=10 -reindex -printtoconsole

Also make plain old 'make' on linux do the right thing.
  • Loading branch information...
catcoiner committed Jul 4, 2015
1 parent a65f953 commit f6650168344edcf7f308ba0a94b7bf90d0eb7832
Showing with 33 additions and 13 deletions.
  1. +1 −1 share/genbuild.sh
  2. +1 −1 src/clientversion.h
  3. +24 −4 src/init.cpp
  4. +7 −7 src/main.cpp
  5. 0 src/{makefile.unix → makefile}
View
@@ -16,7 +16,7 @@ if [ -e "$(which git)" ]; then
git diff >/dev/null 2>/dev/null
# get a string like "v0.6.0-66-g59887e8-dirty"
DESC="$(git describe --dirty 2>/dev/null)"
DESC="$(git describe --always --dirty 2>/dev/null)"
# get a string like "2012-04-10 16:27:19 +0200"
TIME="$(git log -n 1 --format="%ci")"
View
@@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 9
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_BUILD 2
#define CLIENT_VERSION_BUILD 3
// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
View
@@ -620,11 +620,31 @@ bool AppInit2(boost::thread_group& threadGroup)
nConnectTimeout = nNewTimeout;
}
// Continue to put "/P2SH/" in the coinbase to monitor
// BIP16 support.
extern int64 nMinBlockTime;
if (mapArgs.count("-minblocktime"))
{
int nNewMin = GetArg("-minblocktime", 180);
if (nNewMin > 0 && nNewMin < 15*60){
nMinBlockTime = nNewMin;
InitWarning(strprintf(_("HARD minimum block time (nMinBlockTime) set to %d"), nMinBlockTime));
}
}
extern int nForkMinimum;
if (mapArgs.count("-forkminimum"))
{
int64_t nNewFork = GetArg("-forkminimum", 44260);
if (nNewFork > 0 && nNewFork < 999999){
nForkMinimum = nNewFork;
InitWarning(strprintf(_("Minimum block time fork block set to %d"), nForkMinimum));
}
}
// Put "/MIN/" in the coinbase to monitor
// minimum block time support. (like P2SH & BIP16 for bitcoin)
// This can be removed eventually...
const char* pszP2SH = "/P2SH/";
COINBASE_FLAGS << std::vector<unsigned char>(pszP2SH, pszP2SH+strlen(pszP2SH));
const char* pszMIN = "/MIN/";
COINBASE_FLAGS << std::vector<unsigned char>(pszMIN, pszMIN+strlen(pszMIN));
// Fee-per-kilobyte amount considered the same as "free"
// If you are mining, be careful setting this:
View
@@ -1074,8 +1074,8 @@ int64 static GetBlockValue(int nHeight, int64 nFees)
static const int64 nTargetTimespan = 6 * 60 * 60; // 6 hours
static const int64 nTargetSpacing = 10 * 60;
static const int64 nMinSpacing = 120; // Absolute minimum spacing
static const int64 nInterval = nTargetTimespan / nTargetSpacing;
int64 nMinBlockTime = 180; // Absolute minimum spacing
static const int64 nTargetTimespanOld = 14 * 24 * 60 * 60; // two weeks
static const int64 nIntervalOld = nTargetTimespanOld / nTargetSpacing;
@@ -1107,7 +1107,7 @@ unsigned int ComputeMinWork(unsigned int nBase, int64 nTime)
static int fork3Block = 27260; // FIXME move to top...
static int fork4Block = 27680; // Acceptblock needs this
static int fork5Block = 44200; // Acceptblock needs this
int nForkMinimum = 44260; // Acceptblock needs this
unsigned int static GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock)
{
@@ -1266,10 +1266,10 @@ If New diff < 0, then set static value of 0.0001 or so.
nActualTimespan = pindexLast->GetBlockTime() - pindexFirst->GetBlockTime(); // Get last X blocks time
nActualTimespan = nActualTimespan / 8; // Calculate average for last 8 blocks
if(pindexLast->nHeight > fork4Block || fTestNet){
if (30 > nActualTimespan){ // was nMinSpacing
if (30 > nActualTimespan){ // was nMinBlockTime
printf("WARNING: SANITY CHECK FAILED: PID nActualTimespan %"PRI64d" too small! increased to %"PRI64d"\n",
nActualTimespan, nMinSpacing );
nActualTimespan = nMinSpacing;
nActualTimespan, nMinBlockTime );
nActualTimespan = nMinBlockTime;
}
}
bnNew.SetCompact(pindexLast->nBits); // Get current difficulty
@@ -2327,8 +2327,8 @@ bool CBlock::AcceptBlock(CValidationState &state, CDiskBlockPos *dbp)
if (nBits != GetNextWorkRequired(pindexPrev, this))
return state.DoS(100, error("AcceptBlock(height=%d) : incorrect proof of work", nHeight));
if (nHeight > fork5Block){
if (GetBlockTime() <= (pindexPrev->GetBlockTime() + nMinSpacing))
if (nHeight > nForkMinimum){
if (GetBlockTime() <= (pindexPrev->GetBlockTime() + nMinBlockTime))
return state.Invalid(error("AcceptBlock(height=%d) : block's timestamp (%"PRI64d") is too soon after prev(%"PRI64d")", nHeight, GetBlockTime(), pindexPrev->GetBlockTime()));
} else if (nHeight > fork4Block){
if (GetBlockTime() <= (pindexPrev->GetBlockTime() + 30))
File renamed without changes.

0 comments on commit f665016

Please sign in to comment.