Changeset View
Changeset View
Standalone View
Standalone View
src/validation.cpp
Show First 20 Lines • Show All 290 Lines • ▼ Show 20 Lines | for (size_t txinIndex = 0; txinIndex < tx.vin.size(); txinIndex++) { | ||||
continue; | continue; | ||||
} | } | ||||
int nCoinHeight = (*prevHeights)[txinIndex]; | int nCoinHeight = (*prevHeights)[txinIndex]; | ||||
if (txin.nSequence & CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG) { | if (txin.nSequence & CTxIn::SEQUENCE_LOCKTIME_TYPE_FLAG) { | ||||
int64_t nCoinTime = block.GetAncestor(std::max(nCoinHeight - 1, 0)) | int64_t nCoinTime = block.GetAncestor(std::max(nCoinHeight - 1, 0)) | ||||
->GetMedianTimePast(); | ->GetMedianTimePast(); | ||||
// NOTE: Subtract 1 to maintain nLockTime semantics | // NOTE: Subtract 1 to maintain nLockTime semantics. | ||||
// BIP 68 relative lock times have the semantics of calculating | // BIP 68 relative lock times have the semantics of calculating the | ||||
// the first block or time at which the transaction would be | // first block or time at which the transaction would be valid. When | ||||
// valid. When calculating the effective block time or height | // calculating the effective block time or height for the entire | ||||
// for the entire transaction, we switch to using the | // transaction, we switch to using the semantics of nLockTime which | ||||
// semantics of nLockTime which is the last invalid block | // is the last invalid block time or height. Thus we subtract 1 from | ||||
// time or height. Thus we subtract 1 from the calculated | // the calculated time or height. | ||||
// time or height. | |||||
// Time-based relative lock-times are measured from the smallest | |||||
// Time-based relative lock-times are measured from the | // allowed timestamp of the block containing the txout being spent, | ||||
// smallest allowed timestamp of the block containing the | // which is the median time past of the block prior. | ||||
// txout being spent, which is the median time past of the | |||||
// block prior. | |||||
nMinTime = std::max( | nMinTime = std::max( | ||||
nMinTime, | nMinTime, | ||||
nCoinTime + | nCoinTime + | ||||
(int64_t)((txin.nSequence & CTxIn::SEQUENCE_LOCKTIME_MASK) | (int64_t)((txin.nSequence & CTxIn::SEQUENCE_LOCKTIME_MASK) | ||||
<< CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) - | << CTxIn::SEQUENCE_LOCKTIME_GRANULARITY) - | ||||
1); | 1); | ||||
} else { | } else { | ||||
nMinHeight = std::max( | nMinHeight = std::max( | ||||
▲ Show 20 Lines • Show All 773 Lines • ▼ Show 20 Lines | |||||
CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL; | CBlockIndex *pindexBestForkTip = NULL, *pindexBestForkBase = NULL; | ||||
static void AlertNotify(const std::string &strMessage) { | static void AlertNotify(const std::string &strMessage) { | ||||
uiInterface.NotifyAlertChanged(); | uiInterface.NotifyAlertChanged(); | ||||
std::string strCmd = GetArg("-alertnotify", ""); | std::string strCmd = GetArg("-alertnotify", ""); | ||||
if (strCmd.empty()) return; | if (strCmd.empty()) return; | ||||
// Alert text should be plain ascii coming from a trusted source, but to | // Alert text should be plain ascii coming from a trusted source, but to be | ||||
// be safe we first strip anything not in safeChars, then add single quotes | // safe we first strip anything not in safeChars, then add single quotes | ||||
// around | // around the whole string before passing it to the shell: | ||||
// the whole string before passing it to the shell: | |||||
std::string singleQuote("'"); | std::string singleQuote("'"); | ||||
std::string safeStatus = SanitizeString(strMessage); | std::string safeStatus = SanitizeString(strMessage); | ||||
safeStatus = singleQuote + safeStatus + singleQuote; | safeStatus = singleQuote + safeStatus + singleQuote; | ||||
boost::replace_all(strCmd, "%s", safeStatus); | boost::replace_all(strCmd, "%s", safeStatus); | ||||
boost::thread t(runCommand, strCmd); // thread runs free | boost::thread t(runCommand, strCmd); // thread runs free | ||||
} | } | ||||
void CheckForkWarningConditions() { | void CheckForkWarningConditions() { | ||||
AssertLockHeld(cs_main); | AssertLockHeld(cs_main); | ||||
// Before we get past initial download, we cannot reliably alert about forks | // Before we get past initial download, we cannot reliably alert about forks | ||||
// (we assume we don't get stuck on a fork before finishing our initial | // (we assume we don't get stuck on a fork before finishing our initial | ||||
// sync) | // sync) | ||||
if (IsInitialBlockDownload()) return; | if (IsInitialBlockDownload()) return; | ||||
// If our best fork is no longer within 72 blocks (+/- 12 hours if no one | // If our best fork is no longer within 72 blocks (+/- 12 hours if no one | ||||
// mines it) | // mines it) of our head, drop it | ||||
// of our head, drop it | |||||
if (pindexBestForkTip && | if (pindexBestForkTip && | ||||
chainActive.Height() - pindexBestForkTip->nHeight >= 72) | chainActive.Height() - pindexBestForkTip->nHeight >= 72) | ||||
pindexBestForkTip = NULL; | pindexBestForkTip = NULL; | ||||
if (pindexBestForkTip || | if (pindexBestForkTip || | ||||
(pindexBestInvalid && | (pindexBestInvalid && | ||||
pindexBestInvalid->nChainWork > | pindexBestInvalid->nChainWork > | ||||
chainActive.Tip()->nChainWork + | chainActive.Tip()->nChainWork + | ||||
▲ Show 20 Lines • Show All 3,583 Lines • Show Last 20 Lines |