Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TEST] add: "-fastsync" option #178

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ std::string HelpMessage(HelpMessageMode mode)
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)));
strUsage += HelpMessageOpt("-printtoconsole", _("Send trace/debug info to console instead of debug.log file"));
strUsage += HelpMessageOpt("-prunedebuglogfile", _("Prune (limit) filesize of debug.log")); // FIXME.SUGAR // prune debug.log
strUsage += HelpMessageOpt("-fastsync", _("Skip PoW check during IBD for faster sync")); // FIXME.SUGAR // skip PoW check during IBD
if (showDebug)
{
strUsage += HelpMessageOpt("-printpriority", strprintf("Log transaction fee per kB when mining blocks (default: %u)", DEFAULT_PRINTPRIORITY));
Expand Down Expand Up @@ -831,6 +832,7 @@ void InitLogging()
{
fPrintToConsole = gArgs.GetBoolArg("-printtoconsole", false);
fPruneDebugLog = gArgs.GetBoolArg("-prunedebuglogfile", false); // FIXME.SUGAR // prune debug.log
fFastSync = gArgs.GetBoolArg("-fastsync", false); // FIXME.SUGAR // skip PoW check during IBD
fLogTimestamps = gArgs.GetBoolArg("-logtimestamps", DEFAULT_LOGTIMESTAMPS);
fLogTimeMicros = gArgs.GetBoolArg("-logtimemicros", DEFAULT_LOGTIMEMICROS);
fLogIPs = gArgs.GetBoolArg("-logips", DEFAULT_LOGIPS);
Expand Down
8 changes: 8 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,8 @@ uint64_t nPruneTarget = 0;
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE;
bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT;

bool fFastSync = false; // FIXME.SUGAR // skip PoW check during IBD

uint256 hashAssumeValid;
arith_uint256 nMinimumChainWork;

Expand Down Expand Up @@ -3044,6 +3046,12 @@ static bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos,

static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true)
{
// FIXME.SUGAR // skip PoW check during IBD
if (fFastSync == true && IsInitialBlockDownload() == true) {
printf("Fast Sync Mode (fFastSync=%d)\n", fFastSync);
return true;
}

// Check proof of work matches claimed amount
if (fCheckPOW && !CheckProofOfWork(block.GetPoWHash_cached(), block.nBits, consensusParams))
return state.DoS(50, false, REJECT_INVALID, "high-hash", false, "proof of work failed");
Expand Down
8 changes: 5 additions & 3 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ extern CAmount maxTxFee;
extern int64_t nMaxTipAge;
extern bool fEnableReplacement;

extern bool fFastSync; // FIXME.SUGAR // skip PoW check during IBD

/** Block hash whose ancestors we will assume to have valid scripts without checking them. */
extern uint256 hashAssumeValid;

Expand Down Expand Up @@ -230,7 +232,7 @@ static const unsigned int DEFAULT_CHECKLEVEL = 3;
// Setting the target to > than 550MB will make it likely we can respect the target.
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;

/**
/**
* Process an incoming block. This only returns after the best known valid
* block is made active. Note that it does not, however, guarantee that the
* specific block passed to it has been checked for validity!
Expand All @@ -241,7 +243,7 @@ static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 550 * 1024 * 1024;
*
* Note that we guarantee that either the proof-of-work is valid on pblock, or
* (and possibly also) BlockChecked will have been called.
*
*
* Call without cs_main held.
*
* @param[in] pblock The block we want to process.
Expand Down Expand Up @@ -367,7 +369,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp = null

/**
* Closure representing one script verification
* Note that this stores references to the spending transaction
* Note that this stores references to the spending transaction
*/
class CScriptCheck
{
Expand Down