From 24c1d28186a58df828818ee4e4db9c32783c2f3d Mon Sep 17 00:00:00 2001 From: alex Date: Sat, 4 Jan 2014 02:16:31 +0400 Subject: [PATCH] New syncronized checkpoints policy: no immediate PoW block checkpointing. --- src/checkpoints.cpp | 14 +++++--------- src/checkpoints.h | 2 +- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index f9c3c2e..a64243a 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -128,7 +128,7 @@ namespace Checkpoints CBlockIndex* pindex = pindexSyncCheckpoint; while (pindex->nHeight > pindexCheckpointRecv->nHeight) if (!(pindex = pindex->pprev)) - return error("ValidateSyncCheckpoint: pprev1 null - block index structure failure"); + return error("ValidateSyncCheckpoint: pprev null - block index structure failure"); if (pindex->GetBlockHash() != hashCheckpoint) { hashInvalidCheckpoint = hashCheckpoint; @@ -221,14 +221,10 @@ namespace Checkpoints // Automatically select a suitable sync-checkpoint uint256 AutoSelectSyncCheckpoint() { - // Proof-of-work blocks are immediately checkpointed - // to defend against 51% attack which rejects other miners block - - // Select the last proof-of-work block - const CBlockIndex *pindex = GetLastBlockIndex(pindexBest, false); - // Search forward for a block within max span and maturity window - while (pindex->pnext && (pindex->GetBlockTime() + CHECKPOINT_MAX_SPAN <= pindexBest->GetBlockTime() || pindex->nHeight + std::min(6, nCoinbaseMaturity - 20) <= pindexBest->nHeight)) - pindex = pindex->pnext; + const CBlockIndex *pindex = pindexBest; + // Search backward for a block within max span and maturity window + while (pindex->pprev && (pindex->GetBlockTime() + CHECKPOINT_MAX_SPAN > pindexBest->GetBlockTime() || pindex->nHeight + 8 > pindexBest->nHeight)) + pindex = pindex->pprev; return pindex->GetBlockHash(); } diff --git a/src/checkpoints.h b/src/checkpoints.h index a8e7ecb..fedcf36 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -8,7 +8,7 @@ #include "net.h" #include "util.h" -#define CHECKPOINT_MAX_SPAN (60 * 60 * 4) // max 4 hours before latest block +#define CHECKPOINT_MAX_SPAN (60 * 60) // max 1 hour before latest block #ifdef WIN32 #undef STRICT -- 1.7.1