Prefer explicit passing of CChainParams to the Params() global.
This commit is contained in:
parent
e9cc9b4eec
commit
e9b5d83709
|
@ -523,15 +523,15 @@ TEST(ChecktransactionTests, BadTxnsInvalidJoinsplitSignature) {
|
||||||
// during initial block download, for transactions being accepted into the
|
// during initial block download, for transactions being accepted into the
|
||||||
// mempool (and thus not mined), DoS ban score should be zero, else 10
|
// mempool (and thus not mined), DoS ban score should be zero, else 10
|
||||||
EXPECT_CALL(state, DoS(0, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
EXPECT_CALL(state, DoS(0, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const CChainParams&) { return true; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const Consensus::Params&) { return true; });
|
||||||
EXPECT_CALL(state, DoS(10, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
EXPECT_CALL(state, DoS(10, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const CChainParams&) { return false; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const Consensus::Params&) { return false; });
|
||||||
// for transactions that have been mined in a block, DoS ban score should
|
// for transactions that have been mined in a block, DoS ban score should
|
||||||
// always be 100.
|
// always be 100.
|
||||||
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const CChainParams&) { return true; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const Consensus::Params&) { return true; });
|
||||||
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const CChainParams&) { return false; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const Consensus::Params&) { return false; });
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ChecktransactionTests, JoinsplitSignatureDetectsOldBranchId) {
|
TEST(ChecktransactionTests, JoinsplitSignatureDetectsOldBranchId) {
|
||||||
|
@ -553,7 +553,7 @@ TEST(ChecktransactionTests, JoinsplitSignatureDetectsOldBranchId) {
|
||||||
// Ensure that the transaction validates against Sapling.
|
// Ensure that the transaction validates against Sapling.
|
||||||
EXPECT_TRUE(ContextualCheckTransaction(
|
EXPECT_TRUE(ContextualCheckTransaction(
|
||||||
tx, state, chainparams, 5, false,
|
tx, state, chainparams, 5, false,
|
||||||
[](const CChainParams&) { return false; }));
|
[](const Consensus::Params&) { return false; }));
|
||||||
|
|
||||||
// Attempt to validate the inputs against Blossom. We should be notified
|
// Attempt to validate the inputs against Blossom. We should be notified
|
||||||
// that an old consensus branch ID was used for an input.
|
// that an old consensus branch ID was used for an input.
|
||||||
|
@ -565,7 +565,7 @@ TEST(ChecktransactionTests, JoinsplitSignatureDetectsOldBranchId) {
|
||||||
false)).Times(1);
|
false)).Times(1);
|
||||||
EXPECT_FALSE(ContextualCheckTransaction(
|
EXPECT_FALSE(ContextualCheckTransaction(
|
||||||
tx, state, chainparams, 15, false,
|
tx, state, chainparams, 15, false,
|
||||||
[](const CChainParams&) { return false; }));
|
[](const Consensus::Params&) { return false; }));
|
||||||
|
|
||||||
// Attempt to validate the inputs against Heartwood. All we should learn is
|
// Attempt to validate the inputs against Heartwood. All we should learn is
|
||||||
// that the signature is invalid, because we don't check more than one
|
// that the signature is invalid, because we don't check more than one
|
||||||
|
@ -575,7 +575,7 @@ TEST(ChecktransactionTests, JoinsplitSignatureDetectsOldBranchId) {
|
||||||
"bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
"bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
||||||
EXPECT_FALSE(ContextualCheckTransaction(
|
EXPECT_FALSE(ContextualCheckTransaction(
|
||||||
tx, state, chainparams, 25, false,
|
tx, state, chainparams, 25, false,
|
||||||
[](const CChainParams&) { return false; }));
|
[](const Consensus::Params&) { return false; }));
|
||||||
|
|
||||||
// Revert to default
|
// Revert to default
|
||||||
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_HEARTWOOD, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT);
|
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_HEARTWOOD, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT);
|
||||||
|
@ -615,15 +615,15 @@ TEST(ChecktransactionTests, NonCanonicalEd25519Signature) {
|
||||||
// during initial block download, for transactions being accepted into the
|
// during initial block download, for transactions being accepted into the
|
||||||
// mempool (and thus not mined), DoS ban score should be zero, else 10
|
// mempool (and thus not mined), DoS ban score should be zero, else 10
|
||||||
EXPECT_CALL(state, DoS(0, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
EXPECT_CALL(state, DoS(0, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const CChainParams&) { return true; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const Consensus::Params&) { return true; });
|
||||||
EXPECT_CALL(state, DoS(10, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
EXPECT_CALL(state, DoS(10, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const CChainParams&) { return false; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const Consensus::Params&) { return false; });
|
||||||
// for transactions that have been mined in a block, DoS ban score should
|
// for transactions that have been mined in a block, DoS ban score should
|
||||||
// always be 100.
|
// always be 100.
|
||||||
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const CChainParams&) { return true; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const Consensus::Params&) { return true; });
|
||||||
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "bad-txns-invalid-joinsplit-signature", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const CChainParams&) { return false; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const Consensus::Params&) { return false; });
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(ChecktransactionTests, OverwinterConstructors) {
|
TEST(ChecktransactionTests, OverwinterConstructors) {
|
||||||
|
@ -771,7 +771,7 @@ TEST(ChecktransactionTests, OverwinterExpiryHeight) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(checktransaction_tests, BlossomExpiryHeight) {
|
TEST(checktransaction_tests, BlossomExpiryHeight) {
|
||||||
const Consensus::Params& params = RegtestActivateBlossom(false, 100);
|
const Consensus::Params& params = RegtestActivateBlossom(false, 100).GetConsensus();
|
||||||
CMutableTransaction preBlossomMtx = CreateNewContextualCMutableTransaction(params, 99);
|
CMutableTransaction preBlossomMtx = CreateNewContextualCMutableTransaction(params, 99);
|
||||||
EXPECT_EQ(preBlossomMtx.nExpiryHeight, 100 - 1);
|
EXPECT_EQ(preBlossomMtx.nExpiryHeight, 100 - 1);
|
||||||
CMutableTransaction blossomMtx = CreateNewContextualCMutableTransaction(params, 100);
|
CMutableTransaction blossomMtx = CreateNewContextualCMutableTransaction(params, 100);
|
||||||
|
@ -923,15 +923,15 @@ TEST(ChecktransactionTests, OverwinterNotActive) {
|
||||||
// during initial block download, for transactions being accepted into the
|
// during initial block download, for transactions being accepted into the
|
||||||
// mempool (and thus not mined), DoS ban score should be zero, else 10
|
// mempool (and thus not mined), DoS ban score should be zero, else 10
|
||||||
EXPECT_CALL(state, DoS(0, false, REJECT_INVALID, "tx-overwinter-not-active", false)).Times(1);
|
EXPECT_CALL(state, DoS(0, false, REJECT_INVALID, "tx-overwinter-not-active", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const CChainParams&) { return true; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const Consensus::Params&) { return true; });
|
||||||
EXPECT_CALL(state, DoS(10, false, REJECT_INVALID, "tx-overwinter-not-active", false)).Times(1);
|
EXPECT_CALL(state, DoS(10, false, REJECT_INVALID, "tx-overwinter-not-active", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const CChainParams&) { return false; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, false, [](const Consensus::Params&) { return false; });
|
||||||
// for transactions that have been mined in a block, DoS ban score should
|
// for transactions that have been mined in a block, DoS ban score should
|
||||||
// always be 100.
|
// always be 100.
|
||||||
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "tx-overwinter-not-active", false)).Times(1);
|
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "tx-overwinter-not-active", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const CChainParams&) { return true; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const Consensus::Params&) { return true; });
|
||||||
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "tx-overwinter-not-active", false)).Times(1);
|
EXPECT_CALL(state, DoS(100, false, REJECT_INVALID, "tx-overwinter-not-active", false)).Times(1);
|
||||||
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const CChainParams&) { return false; });
|
ContextualCheckTransaction(tx, state, chainparams, 0, true, [](const Consensus::Params&) { return false; });
|
||||||
}
|
}
|
||||||
|
|
||||||
// This tests a transaction without the fOverwintered flag set, against the Overwinter consensus rule set.
|
// This tests a transaction without the fOverwintered flag set, against the Overwinter consensus rule set.
|
||||||
|
@ -1283,7 +1283,6 @@ TEST(ChecktransactionTests, HeartwoodEnforcesSaplingRulesOnShieldedCoinbase) {
|
||||||
|
|
||||||
|
|
||||||
TEST(ChecktransactionTests, CanopyRejectsNonzeroVPubOld) {
|
TEST(ChecktransactionTests, CanopyRejectsNonzeroVPubOld) {
|
||||||
|
|
||||||
RegtestActivateSapling();
|
RegtestActivateSapling();
|
||||||
|
|
||||||
CMutableTransaction mtx = GetValidTransaction(NetworkUpgradeInfo[Consensus::UPGRADE_SAPLING].nBranchId);
|
CMutableTransaction mtx = GetValidTransaction(NetworkUpgradeInfo[Consensus::UPGRADE_SAPLING].nBranchId);
|
||||||
|
|
|
@ -141,7 +141,7 @@ TEST(FoundersRewardTest, General) {
|
||||||
|
|
||||||
TEST(FoundersRewardTest, RegtestGetLastBlockBlossom) {
|
TEST(FoundersRewardTest, RegtestGetLastBlockBlossom) {
|
||||||
int blossomActivationHeight = Consensus::PRE_BLOSSOM_REGTEST_HALVING_INTERVAL / 2; // = 75
|
int blossomActivationHeight = Consensus::PRE_BLOSSOM_REGTEST_HALVING_INTERVAL / 2; // = 75
|
||||||
auto params = RegtestActivateBlossom(false, blossomActivationHeight);
|
auto params = RegtestActivateBlossom(false, blossomActivationHeight).GetConsensus();
|
||||||
int lastFRHeight = params.GetLastFoundersRewardBlockHeight(blossomActivationHeight);
|
int lastFRHeight = params.GetLastFoundersRewardBlockHeight(blossomActivationHeight);
|
||||||
EXPECT_EQ(0, params.Halving(lastFRHeight));
|
EXPECT_EQ(0, params.Halving(lastFRHeight));
|
||||||
EXPECT_EQ(1, params.Halving(lastFRHeight + 1));
|
EXPECT_EQ(1, params.Halving(lastFRHeight + 1));
|
||||||
|
|
|
@ -119,7 +119,7 @@ TEST(Mempool, OverwinterNotActiveYet) {
|
||||||
|
|
||||||
CTransaction tx1(mtx);
|
CTransaction tx1(mtx);
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
EXPECT_FALSE(AcceptToMemoryPool(pool, state1, tx1, false, &missingInputs));
|
EXPECT_FALSE(AcceptToMemoryPool(Params(), pool, state1, tx1, false, &missingInputs));
|
||||||
EXPECT_EQ(state1.GetRejectReason(), "tx-overwinter-not-active");
|
EXPECT_EQ(state1.GetRejectReason(), "tx-overwinter-not-active");
|
||||||
|
|
||||||
// Revert to default
|
// Revert to default
|
||||||
|
@ -144,7 +144,7 @@ TEST(Mempool, SproutV3TxFailsAsExpected) {
|
||||||
CTransaction tx1(mtx);
|
CTransaction tx1(mtx);
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
EXPECT_FALSE(AcceptToMemoryPool(pool, state1, tx1, false, &missingInputs));
|
EXPECT_FALSE(AcceptToMemoryPool(Params(), pool, state1, tx1, false, &missingInputs));
|
||||||
EXPECT_EQ(state1.GetRejectReason(), "version");
|
EXPECT_EQ(state1.GetRejectReason(), "version");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,7 +166,8 @@ TEST(Mempool, SproutV3TxWhenOverwinterActive) {
|
||||||
CTransaction tx1(mtx);
|
CTransaction tx1(mtx);
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
EXPECT_FALSE(AcceptToMemoryPool(pool, state1, tx1, false, &missingInputs));
|
|
||||||
|
EXPECT_FALSE(AcceptToMemoryPool(Params(), pool, state1, tx1, false, &missingInputs));
|
||||||
EXPECT_EQ(state1.GetRejectReason(), "tx-overwintered-flag-not-set");
|
EXPECT_EQ(state1.GetRejectReason(), "tx-overwintered-flag-not-set");
|
||||||
|
|
||||||
// Revert to default
|
// Revert to default
|
||||||
|
@ -202,7 +203,7 @@ TEST(Mempool, SproutNegativeVersionTxWhenOverwinterActive) {
|
||||||
|
|
||||||
CValidationState state1;
|
CValidationState state1;
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
EXPECT_FALSE(AcceptToMemoryPool(pool, state1, tx1, false, &missingInputs));
|
EXPECT_FALSE(AcceptToMemoryPool(Params(), pool, state1, tx1, false, &missingInputs));
|
||||||
EXPECT_EQ(state1.GetRejectReason(), "bad-txns-version-too-low");
|
EXPECT_EQ(state1.GetRejectReason(), "bad-txns-version-too-low");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -219,7 +220,7 @@ TEST(Mempool, SproutNegativeVersionTxWhenOverwinterActive) {
|
||||||
|
|
||||||
CValidationState state1;
|
CValidationState state1;
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
EXPECT_FALSE(AcceptToMemoryPool(pool, state1, tx1, false, &missingInputs));
|
EXPECT_FALSE(AcceptToMemoryPool(Params(), pool, state1, tx1, false, &missingInputs));
|
||||||
EXPECT_EQ(state1.GetRejectReason(), "bad-txns-version-too-low");
|
EXPECT_EQ(state1.GetRejectReason(), "bad-txns-version-too-low");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -252,7 +253,7 @@ TEST(Mempool, ExpiringSoonTxRejection) {
|
||||||
CTransaction tx1(mtx);
|
CTransaction tx1(mtx);
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
EXPECT_FALSE(AcceptToMemoryPool(pool, state1, tx1, false, &missingInputs));
|
EXPECT_FALSE(AcceptToMemoryPool(Params(), pool, state1, tx1, false, &missingInputs));
|
||||||
EXPECT_EQ(state1.GetRejectReason(), "tx-expiring-soon");
|
EXPECT_EQ(state1.GetRejectReason(), "tx-expiring-soon");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ TEST(Metrics, GetLocalSolPS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(Metrics, EstimateNetHeight) {
|
TEST(Metrics, EstimateNetHeight) {
|
||||||
auto params = RegtestActivateBlossom(false, 200);
|
auto params = RegtestActivateBlossom(false, 200).GetConsensus();
|
||||||
int64_t blockTimes[400];
|
int64_t blockTimes[400];
|
||||||
for (int i = 0; i < 400; i++) {
|
for (int i = 0; i < 400; i++) {
|
||||||
blockTimes[i] = i ? blockTimes[i - 1] + params.PoWTargetSpacing(i) : 0;
|
blockTimes[i] = i ? blockTimes[i - 1] + params.PoWTargetSpacing(i) : 0;
|
||||||
|
@ -126,7 +126,7 @@ TEST(Metrics, NextUpgrade) {
|
||||||
EXPECT_EQ(DisplayDuration(SecondsLeftToNextEpoch(params, 99).value(), DurationFormat::REDUCED), "2 minutes");
|
EXPECT_EQ(DisplayDuration(SecondsLeftToNextEpoch(params, 99).value(), DurationFormat::REDUCED), "2 minutes");
|
||||||
EXPECT_EQ(DisplayDuration(SecondsLeftToNextEpoch(params, 99).value(), DurationFormat::FULL), "2 minutes, 30 seconds");
|
EXPECT_EQ(DisplayDuration(SecondsLeftToNextEpoch(params, 99).value(), DurationFormat::FULL), "2 minutes, 30 seconds");
|
||||||
|
|
||||||
auto paramsBlossom = RegtestActivateBlossom(true);
|
auto paramsBlossom = RegtestActivateBlossom(true).GetConsensus();
|
||||||
EXPECT_EQ(SecondsLeftToNextEpoch(paramsBlossom, 1).value(), 7425);
|
EXPECT_EQ(SecondsLeftToNextEpoch(paramsBlossom, 1).value(), 7425);
|
||||||
EXPECT_EQ(DisplayDuration(SecondsLeftToNextEpoch(paramsBlossom, 1).value(), DurationFormat::REDUCED), "2 hours");
|
EXPECT_EQ(DisplayDuration(SecondsLeftToNextEpoch(paramsBlossom, 1).value(), DurationFormat::REDUCED), "2 hours");
|
||||||
EXPECT_EQ(DisplayDuration(SecondsLeftToNextEpoch(paramsBlossom, 1).value(), DurationFormat::FULL), "2 hours, 3 minutes, 45 seconds");
|
EXPECT_EQ(DisplayDuration(SecondsLeftToNextEpoch(paramsBlossom, 1).value(), DurationFormat::FULL), "2 hours, 3 minutes, 45 seconds");
|
||||||
|
|
|
@ -79,7 +79,7 @@ TEST(PoW, DifficultyAveraging) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(PoW, DifficultyAveragingBlossom) {
|
TEST(PoW, DifficultyAveragingBlossom) {
|
||||||
TestDifficultyAveragingImpl(RegtestActivateBlossom(true));
|
TestDifficultyAveragingImpl(RegtestActivateBlossom(true).GetConsensus());
|
||||||
RegtestDeactivateBlossom();
|
RegtestDeactivateBlossom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
src/init.cpp
14
src/init.cpp
|
@ -583,9 +583,8 @@ void CleanupBlockRevFiles()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadImport(std::vector<fs::path> vImportFiles)
|
void ThreadImport(std::vector<fs::path> vImportFiles, const CChainParams& chainparams)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
|
||||||
RenameThread("zcash-loadblk");
|
RenameThread("zcash-loadblk");
|
||||||
// -reindex
|
// -reindex
|
||||||
if (fReindex) {
|
if (fReindex) {
|
||||||
|
@ -1066,7 +1065,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
|
|
||||||
if (!mapMultiArgs["-nuparams"].empty()) {
|
if (!mapMultiArgs["-nuparams"].empty()) {
|
||||||
// Allow overriding network upgrade parameters for testing
|
// Allow overriding network upgrade parameters for testing
|
||||||
if (Params().NetworkIDString() != "regtest") {
|
if (chainparams.NetworkIDString() != "regtest") {
|
||||||
return InitError("Network upgrade parameters may only be overridden on regtest.");
|
return InitError("Network upgrade parameters may only be overridden on regtest.");
|
||||||
}
|
}
|
||||||
const vector<string>& deployments = mapMultiArgs["-nuparams"];
|
const vector<string>& deployments = mapMultiArgs["-nuparams"];
|
||||||
|
@ -1098,14 +1097,14 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapArgs.count("-nurejectoldversions")) {
|
if (mapArgs.count("-nurejectoldversions")) {
|
||||||
if (Params().NetworkIDString() != "regtest") {
|
if (chainparams.NetworkIDString() != "regtest") {
|
||||||
return InitError("-nurejectoldversions may only be set on regtest.");
|
return InitError("-nurejectoldversions may only be set on regtest.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mapMultiArgs["-fundingstream"].empty()) {
|
if (!mapMultiArgs["-fundingstream"].empty()) {
|
||||||
// Allow overriding network upgrade parameters for testing
|
// Allow overriding network upgrade parameters for testing
|
||||||
if (Params().NetworkIDString() != "regtest") {
|
if (chainparams.NetworkIDString() != "regtest") {
|
||||||
return InitError("Funding stream parameters may only be overridden on regtest.");
|
return InitError("Funding stream parameters may only be overridden on regtest.");
|
||||||
}
|
}
|
||||||
const std::vector<std::string>& streams = mapMultiArgs["-fundingstream"];
|
const std::vector<std::string>& streams = mapMultiArgs["-fundingstream"];
|
||||||
|
@ -1136,7 +1135,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
boost::split(vStreamAddrs, vStreamParams[3], boost::is_any_of(","));
|
boost::split(vStreamAddrs, vStreamParams[3], boost::is_any_of(","));
|
||||||
|
|
||||||
auto fs = Consensus::FundingStream::ParseFundingStream(
|
auto fs = Consensus::FundingStream::ParseFundingStream(
|
||||||
Params().GetConsensus(), Params(), nStartHeight, nEndHeight, vStreamAddrs);
|
chainparams.GetConsensus(), chainparams, nStartHeight, nEndHeight, vStreamAddrs);
|
||||||
|
|
||||||
UpdateFundingStreamParameters((Consensus::FundingStreamIndex) nFundingStreamId, fs);
|
UpdateFundingStreamParameters((Consensus::FundingStreamIndex) nFundingStreamId, fs);
|
||||||
}
|
}
|
||||||
|
@ -1658,7 +1657,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
for (const std::string& strFile : mapMultiArgs["-loadblock"])
|
for (const std::string& strFile : mapMultiArgs["-loadblock"])
|
||||||
vImportFiles.push_back(strFile);
|
vImportFiles.push_back(strFile);
|
||||||
}
|
}
|
||||||
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));
|
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles, chainparams));
|
||||||
|
|
||||||
// Wait for genesis block to be processed
|
// Wait for genesis block to be processed
|
||||||
bool fHaveGenesis = false;
|
bool fHaveGenesis = false;
|
||||||
|
@ -1707,6 +1706,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
|
|
||||||
// Monitor the chain every minute, and alert if we get blocks much quicker or slower than expected.
|
// Monitor the chain every minute, and alert if we get blocks much quicker or slower than expected.
|
||||||
CScheduler::Function f = boost::bind(&PartitionCheck, &IsInitialBlockDownload,
|
CScheduler::Function f = boost::bind(&PartitionCheck, &IsInitialBlockDownload,
|
||||||
|
boost::cref(chainparams.GetConsensus()),
|
||||||
boost::ref(cs_main), boost::cref(pindexBestHeader));
|
boost::ref(cs_main), boost::cref(pindexBestHeader));
|
||||||
scheduler.scheduleEvery(f, 60);
|
scheduler.scheduleEvery(f, 60);
|
||||||
|
|
||||||
|
|
134
src/main.cpp
134
src/main.cpp
|
@ -798,7 +798,7 @@ bool ContextualCheckTransaction(
|
||||||
const CChainParams& chainparams,
|
const CChainParams& chainparams,
|
||||||
const int nHeight,
|
const int nHeight,
|
||||||
const bool isMined,
|
const bool isMined,
|
||||||
bool (*isInitBlockDownload)(const CChainParams&))
|
bool (*isInitBlockDownload)(const Consensus::Params&))
|
||||||
{
|
{
|
||||||
const int DOS_LEVEL_BLOCK = 100;
|
const int DOS_LEVEL_BLOCK = 100;
|
||||||
// DoS level set to 10 to be more forgiving.
|
// DoS level set to 10 to be more forgiving.
|
||||||
|
@ -809,7 +809,7 @@ bool ContextualCheckTransaction(
|
||||||
// For rules that are relaxing (or might become relaxing when a future
|
// For rules that are relaxing (or might become relaxing when a future
|
||||||
// network upgrade is implemented), we need to account for IBD mode.
|
// network upgrade is implemented), we need to account for IBD mode.
|
||||||
auto dosLevelPotentiallyRelaxing = isMined ? DOS_LEVEL_BLOCK : (
|
auto dosLevelPotentiallyRelaxing = isMined ? DOS_LEVEL_BLOCK : (
|
||||||
isInitBlockDownload(chainparams) ? 0 : DOS_LEVEL_MEMPOOL);
|
isInitBlockDownload(chainparams.GetConsensus()) ? 0 : DOS_LEVEL_MEMPOOL);
|
||||||
|
|
||||||
bool overwinterActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_OVERWINTER);
|
bool overwinterActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_OVERWINTER);
|
||||||
bool saplingActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_SAPLING);
|
bool saplingActive = chainparams.GetConsensus().NetworkUpgradeActive(nHeight, Consensus::UPGRADE_SAPLING);
|
||||||
|
@ -1428,8 +1428,10 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
|
bool AcceptToMemoryPool(
|
||||||
bool* pfMissingInputs, bool fRejectAbsurdFee)
|
const CChainParams& chainparams,
|
||||||
|
CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
|
||||||
|
bool* pfMissingInputs, bool fRejectAbsurdFee)
|
||||||
{
|
{
|
||||||
AssertLockHeld(cs_main);
|
AssertLockHeld(cs_main);
|
||||||
if (pfMissingInputs)
|
if (pfMissingInputs)
|
||||||
|
@ -1438,7 +1440,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
int nextBlockHeight = chainActive.Height() + 1;
|
int nextBlockHeight = chainActive.Height() + 1;
|
||||||
|
|
||||||
// Grab the branch ID we expect this transaction to commit to.
|
// Grab the branch ID we expect this transaction to commit to.
|
||||||
auto consensusBranchId = CurrentEpochBranchId(nextBlockHeight, Params().GetConsensus());
|
auto consensusBranchId = CurrentEpochBranchId(nextBlockHeight, chainparams.GetConsensus());
|
||||||
|
|
||||||
if (pool.IsRecentlyEvicted(tx.GetHash())) {
|
if (pool.IsRecentlyEvicted(tx.GetHash())) {
|
||||||
LogPrint("mempool", "Dropping txid %s : recently evicted", tx.GetHash().ToString());
|
LogPrint("mempool", "Dropping txid %s : recently evicted", tx.GetHash().ToString());
|
||||||
|
@ -1450,7 +1452,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
return error("AcceptToMemoryPool: CheckTransaction failed");
|
return error("AcceptToMemoryPool: CheckTransaction failed");
|
||||||
|
|
||||||
// Check transaction contextually against the set of consensus rules which apply in the next block to be mined.
|
// Check transaction contextually against the set of consensus rules which apply in the next block to be mined.
|
||||||
if (!ContextualCheckTransaction(tx, state, Params(), nextBlockHeight, false)) {
|
if (!ContextualCheckTransaction(tx, state, chainparams, nextBlockHeight, false)) {
|
||||||
return error("AcceptToMemoryPool: ContextualCheckTransaction failed");
|
return error("AcceptToMemoryPool: ContextualCheckTransaction failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1468,7 +1470,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
|
|
||||||
// Rather not work on nonstandard transactions (unless -testnet/-regtest)
|
// Rather not work on nonstandard transactions (unless -testnet/-regtest)
|
||||||
string reason;
|
string reason;
|
||||||
if (Params().RequireStandard() && !IsStandardTx(tx, reason, Params(), nextBlockHeight))
|
if (chainparams.RequireStandard() && !IsStandardTx(tx, reason, chainparams, nextBlockHeight))
|
||||||
return state.DoS(0,
|
return state.DoS(0,
|
||||||
error("AcceptToMemoryPool: nonstandard transaction: %s", reason),
|
error("AcceptToMemoryPool: nonstandard transaction: %s", reason),
|
||||||
REJECT_NONSTANDARD, reason);
|
REJECT_NONSTANDARD, reason);
|
||||||
|
@ -1563,7 +1565,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for non-standard pay-to-script-hash in inputs
|
// Check for non-standard pay-to-script-hash in inputs
|
||||||
if (Params().RequireStandard() && !AreInputsStandard(tx, view, consensusBranchId))
|
if (chainparams.RequireStandard() && !AreInputsStandard(tx, view, consensusBranchId))
|
||||||
return error("AcceptToMemoryPool: nonstandard transaction input");
|
return error("AcceptToMemoryPool: nonstandard transaction input");
|
||||||
|
|
||||||
// Check that the transaction doesn't have an excessive number of
|
// Check that the transaction doesn't have an excessive number of
|
||||||
|
@ -1652,7 +1654,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
// Check against previous transactions
|
// Check against previous transactions
|
||||||
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
|
// This is done last to help prevent CPU exhaustion denial-of-service attacks.
|
||||||
PrecomputedTransactionData txdata(tx);
|
PrecomputedTransactionData txdata(tx);
|
||||||
if (!ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
|
if (!ContextualCheckInputs(tx, state, view, true, STANDARD_SCRIPT_VERIFY_FLAGS, true, txdata, chainparams.GetConsensus(), consensusBranchId))
|
||||||
{
|
{
|
||||||
return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString());
|
return error("AcceptToMemoryPool: ConnectInputs failed %s", hash.ToString());
|
||||||
}
|
}
|
||||||
|
@ -1666,7 +1668,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
// There is a similar check in CreateNewBlock() to prevent creating
|
// There is a similar check in CreateNewBlock() to prevent creating
|
||||||
// invalid blocks, however allowing such transactions into the mempool
|
// invalid blocks, however allowing such transactions into the mempool
|
||||||
// can be exploited as a DoS attack.
|
// can be exploited as a DoS attack.
|
||||||
if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, Params().GetConsensus(), consensusBranchId))
|
if (!ContextualCheckInputs(tx, state, view, true, MANDATORY_SCRIPT_VERIFY_FLAGS, true, txdata, chainparams.GetConsensus(), consensusBranchId))
|
||||||
{
|
{
|
||||||
return error("AcceptToMemoryPool: BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString());
|
return error("AcceptToMemoryPool: BUG! PLEASE REPORT THIS! ConnectInputs failed against MANDATORY but not STANDARD flags %s", hash.ToString());
|
||||||
}
|
}
|
||||||
|
@ -1676,7 +1678,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
|
||||||
LOCK(pool.cs);
|
LOCK(pool.cs);
|
||||||
|
|
||||||
// Store transaction in memory
|
// Store transaction in memory
|
||||||
pool.addUnchecked(hash, entry, !IsInitialBlockDownload(Params()));
|
pool.addUnchecked(hash, entry, !IsInitialBlockDownload(chainparams.GetConsensus()));
|
||||||
|
|
||||||
// Add memory address index
|
// Add memory address index
|
||||||
if (fAddressIndex) {
|
if (fAddressIndex) {
|
||||||
|
@ -1916,7 +1918,7 @@ CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsInitialBlockDownload(const CChainParams& chainParams)
|
bool IsInitialBlockDownload(const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
// Once this function has returned false, it must remain false.
|
// Once this function has returned false, it must remain false.
|
||||||
static std::atomic<bool> latchToFalse{false};
|
static std::atomic<bool> latchToFalse{false};
|
||||||
|
@ -1931,7 +1933,7 @@ bool IsInitialBlockDownload(const CChainParams& chainParams)
|
||||||
return true;
|
return true;
|
||||||
if (chainActive.Tip() == NULL)
|
if (chainActive.Tip() == NULL)
|
||||||
return true;
|
return true;
|
||||||
if (chainActive.Tip()->nChainWork < UintToArith256(chainParams.GetConsensus().nMinimumChainWork))
|
if (chainActive.Tip()->nChainWork < UintToArith256(params.nMinimumChainWork))
|
||||||
return true;
|
return true;
|
||||||
// Don't bother checking Sprout, it is always active.
|
// Don't bother checking Sprout, it is always active.
|
||||||
for (int idx = Consensus::BASE_SPROUT + 1; idx < Consensus::MAX_NETWORK_UPGRADES; idx++) {
|
for (int idx = Consensus::BASE_SPROUT + 1; idx < Consensus::MAX_NETWORK_UPGRADES; idx++) {
|
||||||
|
@ -1944,9 +1946,9 @@ bool IsInitialBlockDownload(const CChainParams& chainParams)
|
||||||
// Note that this depends on the assumption that if we set hashActivationBlock for
|
// Note that this depends on the assumption that if we set hashActivationBlock for
|
||||||
// any upgrade, we also update nMinimumChainWork to be past that upgrade.
|
// any upgrade, we also update nMinimumChainWork to be past that upgrade.
|
||||||
//
|
//
|
||||||
auto upgrade = chainParams.GetConsensus().vUpgrades[idx];
|
auto upgrade = params.vUpgrades[idx];
|
||||||
if (upgrade.hashActivationBlock) {
|
if (upgrade.hashActivationBlock) {
|
||||||
if (!chainParams.GetConsensus().NetworkUpgradeActive(chainActive.Height(), Consensus::UpgradeIndex(idx))) {
|
if (!params.NetworkUpgradeActive(chainActive.Height(), Consensus::UpgradeIndex(idx))) {
|
||||||
AbortNode(
|
AbortNode(
|
||||||
strprintf(
|
strprintf(
|
||||||
"%s: We are on a chain with sufficient work, but the %s network upgrade has not activated as expected.\n"
|
"%s: We are on a chain with sufficient work, but the %s network upgrade has not activated as expected.\n"
|
||||||
|
@ -1955,7 +1957,7 @@ bool IsInitialBlockDownload(const CChainParams& chainParams)
|
||||||
__func__,
|
__func__,
|
||||||
NetworkUpgradeInfo[idx].strName,
|
NetworkUpgradeInfo[idx].strName,
|
||||||
chainActive.Tip()->nChainWork.GetHex(),
|
chainActive.Tip()->nChainWork.GetHex(),
|
||||||
chainParams.GetConsensus().nMinimumChainWork.GetHex(),
|
params.nMinimumChainWork.GetHex(),
|
||||||
chainActive.Height(),
|
chainActive.Height(),
|
||||||
upgrade.nActivationHeight),
|
upgrade.nActivationHeight),
|
||||||
_("We are on a chain with sufficient work, but an expected network upgrade has not activated. Your node may be under attack! Shutting down for safety."));
|
_("We are on a chain with sufficient work, but an expected network upgrade has not activated. Your node may be under attack! Shutting down for safety."));
|
||||||
|
@ -1974,7 +1976,7 @@ bool IsInitialBlockDownload(const CChainParams& chainParams)
|
||||||
__func__,
|
__func__,
|
||||||
NetworkUpgradeInfo[idx].strName,
|
NetworkUpgradeInfo[idx].strName,
|
||||||
chainActive.Tip()->nChainWork.GetHex(),
|
chainActive.Tip()->nChainWork.GetHex(),
|
||||||
chainParams.GetConsensus().nMinimumChainWork.GetHex(),
|
params.nMinimumChainWork.GetHex(),
|
||||||
chainActive.Height(),
|
chainActive.Height(),
|
||||||
upgrade.nActivationHeight,
|
upgrade.nActivationHeight,
|
||||||
upgrade.hashActivationBlock.get().GetHex(),
|
upgrade.hashActivationBlock.get().GetHex(),
|
||||||
|
@ -1994,12 +1996,12 @@ bool IsInitialBlockDownload(const CChainParams& chainParams)
|
||||||
static CBlockIndex *pindexBestForkTip = NULL;
|
static CBlockIndex *pindexBestForkTip = NULL;
|
||||||
static CBlockIndex *pindexBestForkBase = NULL;
|
static CBlockIndex *pindexBestForkBase = NULL;
|
||||||
|
|
||||||
void CheckForkWarningConditions(const CChainParams& chainParams)
|
void CheckForkWarningConditions(const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
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 sync)
|
// (we assume we don't get stuck on a fork before finishing our initial sync)
|
||||||
if (IsInitialBlockDownload(chainParams))
|
if (IsInitialBlockDownload(params))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If our best fork is no longer within 288 blocks (+/- 12 hours if no one mines it)
|
// If our best fork is no longer within 288 blocks (+/- 12 hours if no one mines it)
|
||||||
|
@ -2067,7 +2069,7 @@ void CheckForkWarningConditionsOnNewFork(CBlockIndex* pindexNewForkTip, const CC
|
||||||
pindexBestForkBase = pfork;
|
pindexBestForkBase = pfork;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckForkWarningConditions(chainParams);
|
CheckForkWarningConditions(chainParams.GetConsensus());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Requires cs_main.
|
// Requires cs_main.
|
||||||
|
@ -2104,7 +2106,7 @@ void static InvalidChainFound(CBlockIndex* pindexNew, const CChainParams& chainP
|
||||||
LogPrintf("%s: current best=%s height=%d log2_work=%.8g date=%s\n", __func__,
|
LogPrintf("%s: current best=%s height=%d log2_work=%.8g date=%s\n", __func__,
|
||||||
tip->GetBlockHash().ToString(), chainActive.Height(), log2(tip->nChainWork.getdouble()),
|
tip->GetBlockHash().ToString(), chainActive.Height(), log2(tip->nChainWork.getdouble()),
|
||||||
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", tip->GetBlockTime()));
|
DateTimeStrFormat("%Y-%m-%d %H:%M:%S", tip->GetBlockTime()));
|
||||||
CheckForkWarningConditions(chainParams);
|
CheckForkWarningConditions(chainParams.GetConsensus());
|
||||||
}
|
}
|
||||||
|
|
||||||
void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state, const CChainParams& chainParams) {
|
void static InvalidBlockFound(CBlockIndex *pindex, const CValidationState &state, const CChainParams& chainParams) {
|
||||||
|
@ -2640,10 +2642,13 @@ void ThreadScriptCheck() {
|
||||||
// Called periodically asynchronously; alerts if it smells like
|
// Called periodically asynchronously; alerts if it smells like
|
||||||
// we're being fed a bad chain (blocks being generated much
|
// we're being fed a bad chain (blocks being generated much
|
||||||
// too slowly or too quickly).
|
// too slowly or too quickly).
|
||||||
void PartitionCheck(bool (*initialDownloadCheck)(const CChainParams&),
|
void PartitionCheck(
|
||||||
CCriticalSection& cs, const CBlockIndex *const &bestHeader)
|
bool (*initialDownloadCheck)(const Consensus::Params&),
|
||||||
|
const Consensus::Params& consensusParams,
|
||||||
|
CCriticalSection& cs,
|
||||||
|
const CBlockIndex *const &bestHeader)
|
||||||
{
|
{
|
||||||
if (bestHeader == NULL || initialDownloadCheck(Params())) return;
|
if (bestHeader == NULL || initialDownloadCheck(consensusParams)) return;
|
||||||
|
|
||||||
static int64_t lastAlertTime = 0;
|
static int64_t lastAlertTime = 0;
|
||||||
int64_t now = GetTime();
|
int64_t now = GetTime();
|
||||||
|
@ -2654,8 +2659,6 @@ void PartitionCheck(bool (*initialDownloadCheck)(const CChainParams&),
|
||||||
|
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
|
||||||
|
|
||||||
int BLOCKS_EXPECTED;
|
int BLOCKS_EXPECTED;
|
||||||
// TODO: This can be simplified when the Blossom activation height is set
|
// TODO: This can be simplified when the Blossom activation height is set
|
||||||
int nBlossomBlocks = consensusParams.vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight == Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT ?
|
int nBlossomBlocks = consensusParams.vUpgrades[Consensus::UPGRADE_BLOSSOM].nActivationHeight == Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT ?
|
||||||
|
@ -2730,7 +2733,7 @@ static int64_t nTimeTotal = 0;
|
||||||
static bool ShouldCheckTransactions(const CChainParams& chainparams, const CBlockIndex* pindex) {
|
static bool ShouldCheckTransactions(const CChainParams& chainparams, const CBlockIndex* pindex) {
|
||||||
return !(fIBDSkipTxVerification
|
return !(fIBDSkipTxVerification
|
||||||
&& fCheckpointsEnabled
|
&& fCheckpointsEnabled
|
||||||
&& IsInitialBlockDownload(chainparams)
|
&& IsInitialBlockDownload(chainparams.GetConsensus())
|
||||||
&& Checkpoints::IsAncestorOfLastCheckpoint(chainparams.Checkpoints(), pindex));
|
&& Checkpoints::IsAncestorOfLastCheckpoint(chainparams.Checkpoints(), pindex));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3176,8 +3179,10 @@ enum FlushStateMode {
|
||||||
* if they're too large, if it's been a while since the last write,
|
* if they're too large, if it's been a while since the last write,
|
||||||
* or always and in all cases if we're in prune mode and are deleting files.
|
* or always and in all cases if we're in prune mode and are deleting files.
|
||||||
*/
|
*/
|
||||||
bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
|
bool static FlushStateToDisk(
|
||||||
const CChainParams& chainparams = Params();
|
const CChainParams& chainparams,
|
||||||
|
CValidationState &state,
|
||||||
|
FlushStateMode mode) {
|
||||||
LOCK2(cs_main, cs_LastBlockFile);
|
LOCK2(cs_main, cs_LastBlockFile);
|
||||||
static int64_t nLastWrite = 0;
|
static int64_t nLastWrite = 0;
|
||||||
static int64_t nLastFlush = 0;
|
static int64_t nLastFlush = 0;
|
||||||
|
@ -3267,13 +3272,13 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
|
||||||
|
|
||||||
void FlushStateToDisk() {
|
void FlushStateToDisk() {
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
|
FlushStateToDisk(Params(), state, FLUSH_STATE_ALWAYS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PruneAndFlush() {
|
void PruneAndFlush() {
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
fCheckForPruning = true;
|
fCheckForPruning = true;
|
||||||
FlushStateToDisk(state, FLUSH_STATE_NONE);
|
FlushStateToDisk(Params(), state, FLUSH_STATE_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Update chainActive and related internal data structures. */
|
/** Update chainActive and related internal data structures. */
|
||||||
|
@ -3333,7 +3338,7 @@ bool static DisconnectTip(CValidationState &state, const CChainParams& chainpara
|
||||||
uint256 sproutAnchorAfterDisconnect = pcoinsTip->GetBestAnchor(SPROUT);
|
uint256 sproutAnchorAfterDisconnect = pcoinsTip->GetBestAnchor(SPROUT);
|
||||||
uint256 saplingAnchorAfterDisconnect = pcoinsTip->GetBestAnchor(SAPLING);
|
uint256 saplingAnchorAfterDisconnect = pcoinsTip->GetBestAnchor(SAPLING);
|
||||||
// Write the chain state to disk, if necessary.
|
// Write the chain state to disk, if necessary.
|
||||||
if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED))
|
if (!FlushStateToDisk(chainparams, state, FLUSH_STATE_IF_NEEDED))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!fBare) {
|
if (!fBare) {
|
||||||
|
@ -3342,7 +3347,7 @@ bool static DisconnectTip(CValidationState &state, const CChainParams& chainpara
|
||||||
// ignore validation errors in resurrected transactions
|
// ignore validation errors in resurrected transactions
|
||||||
list<CTransaction> removed;
|
list<CTransaction> removed;
|
||||||
CValidationState stateDummy;
|
CValidationState stateDummy;
|
||||||
if (tx.IsCoinBase() || !AcceptToMemoryPool(mempool, stateDummy, tx, false, NULL))
|
if (tx.IsCoinBase() || !AcceptToMemoryPool(chainparams, mempool, stateDummy, tx, false, NULL))
|
||||||
mempool.remove(tx, removed, true);
|
mempool.remove(tx, removed, true);
|
||||||
}
|
}
|
||||||
if (sproutAnchorBeforeDisconnect != sproutAnchorAfterDisconnect) {
|
if (sproutAnchorBeforeDisconnect != sproutAnchorAfterDisconnect) {
|
||||||
|
@ -3406,13 +3411,13 @@ bool static ConnectTip(CValidationState& state, const CChainParams& chainparams,
|
||||||
int64_t nTime4 = GetTimeMicros(); nTimeFlush += nTime4 - nTime3;
|
int64_t nTime4 = GetTimeMicros(); nTimeFlush += nTime4 - nTime3;
|
||||||
LogPrint("bench", " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001);
|
LogPrint("bench", " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001);
|
||||||
// Write the chain state to disk, if necessary.
|
// Write the chain state to disk, if necessary.
|
||||||
if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED))
|
if (!FlushStateToDisk(chainparams, state, FLUSH_STATE_IF_NEEDED))
|
||||||
return false;
|
return false;
|
||||||
int64_t nTime5 = GetTimeMicros(); nTimeChainState += nTime5 - nTime4;
|
int64_t nTime5 = GetTimeMicros(); nTimeChainState += nTime5 - nTime4;
|
||||||
LogPrint("bench", " - Writing chainstate: %.2fms [%.2fs]\n", (nTime5 - nTime4) * 0.001, nTimeChainState * 0.000001);
|
LogPrint("bench", " - Writing chainstate: %.2fms [%.2fs]\n", (nTime5 - nTime4) * 0.001, nTimeChainState * 0.000001);
|
||||||
// Remove conflicting transactions from the mempool.
|
// Remove conflicting transactions from the mempool.
|
||||||
std::list<CTransaction> txConflicted;
|
std::list<CTransaction> txConflicted;
|
||||||
mempool.removeForBlock(pblock->vtx, pindexNew->nHeight, txConflicted, !IsInitialBlockDownload(chainparams));
|
mempool.removeForBlock(pblock->vtx, pindexNew->nHeight, txConflicted, !IsInitialBlockDownload(chainparams.GetConsensus()));
|
||||||
|
|
||||||
// Remove transactions that expire at new block height from mempool
|
// Remove transactions that expire at new block height from mempool
|
||||||
auto ids = mempool.removeExpired(pindexNew->nHeight);
|
auto ids = mempool.removeExpired(pindexNew->nHeight);
|
||||||
|
@ -3450,14 +3455,14 @@ std::pair<std::map<CBlockIndex*, std::list<CTransaction>>, uint64_t> DrainRecent
|
||||||
return std::make_pair(txs, recentlyConflictedSequence);
|
return std::make_pair(txs, recentlyConflictedSequence);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetChainNotifiedSequence(uint64_t recentlyConflictedSequence) {
|
void SetChainNotifiedSequence(const CChainParams& chainparams, uint64_t recentlyConflictedSequence) {
|
||||||
assert(Params().NetworkIDString() == "regtest");
|
assert(chainparams.NetworkIDString() == "regtest");
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
nNotifiedSequence = recentlyConflictedSequence;
|
nNotifiedSequence = recentlyConflictedSequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChainIsFullyNotified() {
|
bool ChainIsFullyNotified(const CChainParams& chainparams) {
|
||||||
assert(Params().NetworkIDString() == "regtest");
|
assert(chainparams.NetworkIDString() == "regtest");
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
return nRecentlyConflictedSequence == nNotifiedSequence;
|
return nRecentlyConflictedSequence == nNotifiedSequence;
|
||||||
}
|
}
|
||||||
|
@ -3641,7 +3646,7 @@ static bool ActivateBestChainStep(CValidationState& state, const CChainParams& c
|
||||||
if (fInvalidFound)
|
if (fInvalidFound)
|
||||||
CheckForkWarningConditionsOnNewFork(vpindexToConnect.back(), chainparams);
|
CheckForkWarningConditionsOnNewFork(vpindexToConnect.back(), chainparams);
|
||||||
else
|
else
|
||||||
CheckForkWarningConditions(chainparams);
|
CheckForkWarningConditions(chainparams.GetConsensus());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -3671,7 +3676,7 @@ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams,
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pindexNewTip = chainActive.Tip();
|
pindexNewTip = chainActive.Tip();
|
||||||
fInitialDownload = IsInitialBlockDownload(chainparams);
|
fInitialDownload = IsInitialBlockDownload(chainparams.GetConsensus());
|
||||||
}
|
}
|
||||||
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
|
// When we reach this point, we switched to a new tip (stored in pindexNewTip).
|
||||||
|
|
||||||
|
@ -3697,7 +3702,7 @@ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams,
|
||||||
CheckBlockIndex(chainparams.GetConsensus());
|
CheckBlockIndex(chainparams.GetConsensus());
|
||||||
|
|
||||||
// Write changes periodically to disk, after relay.
|
// Write changes periodically to disk, after relay.
|
||||||
if (!FlushStateToDisk(state, FLUSH_STATE_PERIODIC)) {
|
if (!FlushStateToDisk(chainparams, state, FLUSH_STATE_PERIODIC)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4383,7 +4388,7 @@ static bool AcceptBlock(const CBlock& block, CValidationState& state, const CCha
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fCheckForPruning)
|
if (fCheckForPruning)
|
||||||
FlushStateToDisk(state, FLUSH_STATE_NONE); // we just allocated more disk space for block files
|
FlushStateToDisk(chainparams, state, FLUSH_STATE_NONE); // we just allocated more disk space for block files
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4630,9 +4635,8 @@ CBlockIndex * InsertBlockIndex(uint256 hash)
|
||||||
return pindexNew;
|
return pindexNew;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool static LoadBlockIndexDB()
|
bool static LoadBlockIndexDB(const CChainParams& chainparams)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
|
||||||
if (!pblocktree->LoadBlockIndexGuts(InsertBlockIndex, chainparams))
|
if (!pblocktree->LoadBlockIndexGuts(InsertBlockIndex, chainparams))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -5007,7 +5011,7 @@ bool RewindBlockIndex(const CChainParams& chainparams, bool& clearWitnessCaches)
|
||||||
return error("RewindBlockIndex: unable to disconnect block at height %i", pindex->nHeight);
|
return error("RewindBlockIndex: unable to disconnect block at height %i", pindex->nHeight);
|
||||||
}
|
}
|
||||||
// Occasionally flush state to disk.
|
// Occasionally flush state to disk.
|
||||||
if (!FlushStateToDisk(state, FLUSH_STATE_PERIODIC))
|
if (!FlushStateToDisk(chainparams, state, FLUSH_STATE_PERIODIC))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5067,7 +5071,7 @@ bool RewindBlockIndex(const CChainParams& chainparams, bool& clearWitnessCaches)
|
||||||
|
|
||||||
CheckBlockIndex(chainparams.GetConsensus());
|
CheckBlockIndex(chainparams.GetConsensus());
|
||||||
|
|
||||||
if (!FlushStateToDisk(state, FLUSH_STATE_ALWAYS)) {
|
if (!FlushStateToDisk(chainparams, state, FLUSH_STATE_ALWAYS)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5108,7 +5112,7 @@ void UnloadBlockIndex()
|
||||||
bool LoadBlockIndex()
|
bool LoadBlockIndex()
|
||||||
{
|
{
|
||||||
// Load block index from databases
|
// Load block index from databases
|
||||||
if (!fReindex && !LoadBlockIndexDB())
|
if (!fReindex && !LoadBlockIndexDB(Params()))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -5160,7 +5164,7 @@ bool InitBlockIndex(const CChainParams& chainparams)
|
||||||
if (!ActivateBestChain(state, chainparams, &block))
|
if (!ActivateBestChain(state, chainparams, &block))
|
||||||
return error("LoadBlockIndex(): genesis block cannot be activated");
|
return error("LoadBlockIndex(): genesis block cannot be activated");
|
||||||
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
|
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
|
||||||
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
|
return FlushStateToDisk(chainparams, state, FLUSH_STATE_ALWAYS);
|
||||||
} catch (const std::runtime_error& e) {
|
} catch (const std::runtime_error& e) {
|
||||||
return error("LoadBlockIndex(): failed to initialize block database: %s", e.what());
|
return error("LoadBlockIndex(): failed to initialize block database: %s", e.what());
|
||||||
}
|
}
|
||||||
|
@ -5641,9 +5645,8 @@ void static ProcessGetData(CNode* pfrom, const Consensus::Params& consensusParam
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived)
|
bool static ProcessMessage(const CChainParams& chainparams, CNode* pfrom, string strCommand, CDataStream& vRecv, int64_t nTimeReceived)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
|
||||||
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
|
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
|
||||||
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
|
||||||
{
|
{
|
||||||
|
@ -5739,7 +5742,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
if (!pfrom->fInbound)
|
if (!pfrom->fInbound)
|
||||||
{
|
{
|
||||||
// Advertise our address
|
// Advertise our address
|
||||||
if (fListen && !IsInitialBlockDownload(chainparams))
|
if (fListen && !IsInitialBlockDownload(chainparams.GetConsensus()))
|
||||||
{
|
{
|
||||||
CAddress addr = GetLocalAddress(&pfrom->addr);
|
CAddress addr = GetLocalAddress(&pfrom->addr);
|
||||||
FastRandomContext insecure_rand;
|
FastRandomContext insecure_rand;
|
||||||
|
@ -6038,7 +6041,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
|
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
if (IsInitialBlockDownload(chainparams))
|
if (IsInitialBlockDownload(chainparams.GetConsensus()))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
CBlockIndex* pindex = NULL;
|
CBlockIndex* pindex = NULL;
|
||||||
|
@ -6090,7 +6093,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
pfrom->setAskFor.erase(inv.hash);
|
pfrom->setAskFor.erase(inv.hash);
|
||||||
mapAlreadyAskedFor.erase(inv);
|
mapAlreadyAskedFor.erase(inv);
|
||||||
|
|
||||||
if (!AlreadyHave(inv) && AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
|
if (!AlreadyHave(inv) && AcceptToMemoryPool(chainparams, mempool, state, tx, true, &fMissingInputs))
|
||||||
{
|
{
|
||||||
mempool.check(pcoinsTip);
|
mempool.check(pcoinsTip);
|
||||||
RelayTransaction(tx);
|
RelayTransaction(tx);
|
||||||
|
@ -6124,7 +6127,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
|
|
||||||
if (setMisbehaving.count(fromPeer))
|
if (setMisbehaving.count(fromPeer))
|
||||||
continue;
|
continue;
|
||||||
if (AcceptToMemoryPool(mempool, stateDummy, orphanTx, true, &fMissingInputs2))
|
if (AcceptToMemoryPool(chainparams, mempool, stateDummy, orphanTx, true, &fMissingInputs2))
|
||||||
{
|
{
|
||||||
LogPrint("mempool", " accepted orphan tx %s\n", orphanHash.ToString());
|
LogPrint("mempool", " accepted orphan tx %s\n", orphanHash.ToString());
|
||||||
RelayTransaction(orphanTx);
|
RelayTransaction(orphanTx);
|
||||||
|
@ -6274,7 +6277,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
// unless we're still syncing with the network.
|
// unless we're still syncing with the network.
|
||||||
// Such an unrequested block may still be processed, subject to the
|
// Such an unrequested block may still be processed, subject to the
|
||||||
// conditions in AcceptBlock().
|
// conditions in AcceptBlock().
|
||||||
bool forceProcessing = pfrom->fWhitelisted && !IsInitialBlockDownload(chainparams);
|
bool forceProcessing = pfrom->fWhitelisted && !IsInitialBlockDownload(chainparams.GetConsensus());
|
||||||
ProcessNewBlock(state, chainparams, pfrom, &block, forceProcessing, NULL);
|
ProcessNewBlock(state, chainparams, pfrom, &block, forceProcessing, NULL);
|
||||||
int nDoS;
|
int nDoS;
|
||||||
if (state.IsInvalid(nDoS)) {
|
if (state.IsInvalid(nDoS)) {
|
||||||
|
@ -6559,9 +6562,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||||
}
|
}
|
||||||
|
|
||||||
// requires LOCK(cs_vRecvMsg)
|
// requires LOCK(cs_vRecvMsg)
|
||||||
bool ProcessMessages(CNode* pfrom)
|
bool ProcessMessages(const CChainParams& chainparams, CNode* pfrom)
|
||||||
{
|
{
|
||||||
const CChainParams& chainparams = Params();
|
|
||||||
//if (fDebug)
|
//if (fDebug)
|
||||||
// LogPrintf("%s(%u messages)\n", __func__, pfrom->vRecvMsg.size());
|
// LogPrintf("%s(%u messages)\n", __func__, pfrom->vRecvMsg.size());
|
||||||
|
|
||||||
|
@ -6636,7 +6638,7 @@ bool ProcessMessages(CNode* pfrom)
|
||||||
bool fRet = false;
|
bool fRet = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
fRet = ProcessMessage(pfrom, strCommand, vRecv, msg.nTime);
|
fRet = ProcessMessage(chainparams, pfrom, strCommand, vRecv, msg.nTime);
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
}
|
}
|
||||||
catch (const std::ios_base::failure& e)
|
catch (const std::ios_base::failure& e)
|
||||||
|
@ -6680,10 +6682,8 @@ bool ProcessMessages(CNode* pfrom)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SendMessages(CNode* pto, bool fSendTrickle)
|
bool SendMessages(const Consensus::Params& params, CNode* pto, bool fSendTrickle)
|
||||||
{
|
{
|
||||||
const CChainParams& chainParams = Params();
|
|
||||||
const Consensus::Params& consensusParams = chainParams.GetConsensus();
|
|
||||||
{
|
{
|
||||||
// Don't send anything until we get its version message
|
// Don't send anything until we get its version message
|
||||||
if (pto->nVersion == 0)
|
if (pto->nVersion == 0)
|
||||||
|
@ -6724,7 +6724,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||||
|
|
||||||
// Address refresh broadcast
|
// Address refresh broadcast
|
||||||
static int64_t nLastRebroadcast;
|
static int64_t nLastRebroadcast;
|
||||||
if (!IsInitialBlockDownload(chainParams) && (GetTime() - nLastRebroadcast > 24 * 60 * 60))
|
if (!IsInitialBlockDownload(params) && (GetTime() - nLastRebroadcast > 24 * 60 * 60))
|
||||||
{
|
{
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
for (CNode* pnode : vNodes)
|
for (CNode* pnode : vNodes)
|
||||||
|
@ -6804,7 +6804,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||||
// Resend wallet transactions that haven't gotten in a block yet
|
// Resend wallet transactions that haven't gotten in a block yet
|
||||||
// Except during reindex, importing and IBD, when old wallet
|
// Except during reindex, importing and IBD, when old wallet
|
||||||
// transactions become unconfirmed and spams other nodes.
|
// transactions become unconfirmed and spams other nodes.
|
||||||
if (!fReindex && !fImporting && !IsInitialBlockDownload(chainParams))
|
if (!fReindex && !fImporting && !IsInitialBlockDownload(params))
|
||||||
{
|
{
|
||||||
GetMainSignals().Broadcast(nTimeBestReceived);
|
GetMainSignals().Broadcast(nTimeBestReceived);
|
||||||
}
|
}
|
||||||
|
@ -6878,7 +6878,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||||
// more quickly than once every 5 minutes, then we'll shorten the download window for this block).
|
// more quickly than once every 5 minutes, then we'll shorten the download window for this block).
|
||||||
if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0) {
|
if (!pto->fDisconnect && state.vBlocksInFlight.size() > 0) {
|
||||||
QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
|
QueuedBlock &queuedBlock = state.vBlocksInFlight.front();
|
||||||
int64_t nTimeoutIfRequestedNow = GetBlockTimeout(nNow, nQueuedValidatedHeaders - state.nBlocksInFlightValidHeaders, consensusParams, pindexBestHeader->nHeight);
|
int64_t nTimeoutIfRequestedNow = GetBlockTimeout(nNow, nQueuedValidatedHeaders - state.nBlocksInFlightValidHeaders, params, pindexBestHeader->nHeight);
|
||||||
if (queuedBlock.nTimeDisconnect > nTimeoutIfRequestedNow) {
|
if (queuedBlock.nTimeDisconnect > nTimeoutIfRequestedNow) {
|
||||||
LogPrint("net", "Reducing block download timeout for peer=%d block=%s, orig=%d new=%d\n", pto->id, queuedBlock.hash.ToString(), queuedBlock.nTimeDisconnect, nTimeoutIfRequestedNow);
|
LogPrint("net", "Reducing block download timeout for peer=%d block=%s, orig=%d new=%d\n", pto->id, queuedBlock.hash.ToString(), queuedBlock.nTimeDisconnect, nTimeoutIfRequestedNow);
|
||||||
queuedBlock.nTimeDisconnect = nTimeoutIfRequestedNow;
|
queuedBlock.nTimeDisconnect = nTimeoutIfRequestedNow;
|
||||||
|
@ -6893,13 +6893,13 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
|
||||||
// Message: getdata (blocks)
|
// Message: getdata (blocks)
|
||||||
//
|
//
|
||||||
vector<CInv> vGetData;
|
vector<CInv> vGetData;
|
||||||
if (!pto->fDisconnect && !pto->fClient && (fFetch || !IsInitialBlockDownload(chainParams)) && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
|
if (!pto->fDisconnect && !pto->fClient && (fFetch || !IsInitialBlockDownload(params)) && state.nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) {
|
||||||
vector<CBlockIndex*> vToDownload;
|
vector<CBlockIndex*> vToDownload;
|
||||||
NodeId staller = -1;
|
NodeId staller = -1;
|
||||||
FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller);
|
FindNextBlocksToDownload(pto->GetId(), MAX_BLOCKS_IN_TRANSIT_PER_PEER - state.nBlocksInFlight, vToDownload, staller);
|
||||||
for (CBlockIndex *pindex : vToDownload) {
|
for (CBlockIndex *pindex : vToDownload) {
|
||||||
vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash()));
|
vGetData.push_back(CInv(MSG_BLOCK, pindex->GetBlockHash()));
|
||||||
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), consensusParams, pindex);
|
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), params, pindex);
|
||||||
LogPrint("net", "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
|
LogPrint("net", "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(),
|
||||||
pindex->nHeight, pto->id);
|
pindex->nHeight, pto->id);
|
||||||
}
|
}
|
||||||
|
|
27
src/main.h
27
src/main.h
|
@ -243,21 +243,26 @@ bool LoadBlockIndex();
|
||||||
/** Unload database information */
|
/** Unload database information */
|
||||||
void UnloadBlockIndex();
|
void UnloadBlockIndex();
|
||||||
/** Process protocol messages received from a given node */
|
/** Process protocol messages received from a given node */
|
||||||
bool ProcessMessages(CNode* pfrom);
|
bool ProcessMessages(const CChainParams& chainparams, CNode* pfrom);
|
||||||
/**
|
/**
|
||||||
* Send queued protocol messages to be sent to a give node.
|
* Send queued protocol messages to be sent to a give node.
|
||||||
*
|
*
|
||||||
|
* @param[in] params Active chain parameters.
|
||||||
* @param[in] pto The node which we are sending messages to.
|
* @param[in] pto The node which we are sending messages to.
|
||||||
* @param[in] fSendTrickle When true send the trickled data, otherwise trickle the data until true.
|
* @param[in] fSendTrickle When true send the trickled data, otherwise trickle the data until true.
|
||||||
*/
|
*/
|
||||||
bool SendMessages(CNode* pto, bool fSendTrickle);
|
bool SendMessages(const Consensus::Params& params, CNode* pto, bool fSendTrickle);
|
||||||
/** Run an instance of the script checking thread */
|
/** Run an instance of the script checking thread */
|
||||||
void ThreadScriptCheck();
|
void ThreadScriptCheck();
|
||||||
/** Try to detect Partition (network isolation) attacks against us */
|
/** Try to detect Partition (network isolation) attacks against us */
|
||||||
void PartitionCheck(bool (*initialDownloadCheck)(const CChainParams&), CCriticalSection& cs, const CBlockIndex *const &bestHeader);
|
void PartitionCheck(
|
||||||
|
bool (*initialDownloadCheck)(const Consensus::Params&),
|
||||||
|
const Consensus::Params& params,
|
||||||
|
CCriticalSection& cs,
|
||||||
|
const CBlockIndex *const &bestHeader);
|
||||||
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
/** Check whether we are doing an initial block download (synchronizing from disk or network) */
|
||||||
bool IsInitialBlockDownload(const CChainParams& chainParams);
|
bool IsInitialBlockDownload(const Consensus::Params& params);
|
||||||
/** Pair of timestamp and formatted string that describes several potential problems detected by the core */
|
/** Format a string that describes several potential problems detected by the core */
|
||||||
std::pair<std::string, int64_t> GetWarnings(const std::string& strFor);
|
std::pair<std::string, int64_t> GetWarnings(const std::string& strFor);
|
||||||
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
|
/** Retrieve a transaction (from memory pool, or from disk, if possible) */
|
||||||
bool GetTransaction(const uint256& hash, CTransaction& tx, const Consensus::Params& params, uint256& hashBlock, bool fAllowSlow = false, CBlockIndex* blockIndex = nullptr);
|
bool GetTransaction(const uint256& hash, CTransaction& tx, const Consensus::Params& params, uint256& hashBlock, bool fAllowSlow = false, CBlockIndex* blockIndex = nullptr);
|
||||||
|
@ -299,8 +304,10 @@ void FlushStateToDisk();
|
||||||
void PruneAndFlush();
|
void PruneAndFlush();
|
||||||
|
|
||||||
/** (try to) add transaction to memory pool **/
|
/** (try to) add transaction to memory pool **/
|
||||||
bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
|
bool AcceptToMemoryPool(
|
||||||
bool* pfMissingInputs, bool fRejectAbsurdFee=false);
|
const CChainParams& chainparams,
|
||||||
|
CTxMemPool& pool, CValidationState &state, const CTransaction &tx, bool fLimitFree,
|
||||||
|
bool* pfMissingInputs, bool fRejectAbsurdFee=false);
|
||||||
|
|
||||||
|
|
||||||
struct CNodeStateStats {
|
struct CNodeStateStats {
|
||||||
|
@ -344,7 +351,7 @@ bool ContextualCheckInputs(const CTransaction& tx, CValidationState &state, cons
|
||||||
/** Check a transaction contextually against a set of consensus rules */
|
/** Check a transaction contextually against a set of consensus rules */
|
||||||
bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state,
|
bool ContextualCheckTransaction(const CTransaction& tx, CValidationState &state,
|
||||||
const CChainParams& chainparams, int nHeight, bool isMined,
|
const CChainParams& chainparams, int nHeight, bool isMined,
|
||||||
bool (*isInitBlockDownload)(const CChainParams&) = IsInitialBlockDownload);
|
bool (*isInitBlockDownload)(const Consensus::Params&) = IsInitialBlockDownload);
|
||||||
|
|
||||||
/** Apply the effects of this transaction on the UTXO set represented by view */
|
/** Apply the effects of this transaction on the UTXO set represented by view */
|
||||||
void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight);
|
void UpdateCoins(const CTransaction& tx, CCoinsViewCache& inputs, int nHeight);
|
||||||
|
@ -537,7 +544,7 @@ uint64_t CalculateCurrentUsage();
|
||||||
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight);
|
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight);
|
||||||
|
|
||||||
std::pair<std::map<CBlockIndex*, std::list<CTransaction>>, uint64_t> DrainRecentlyConflicted();
|
std::pair<std::map<CBlockIndex*, std::list<CTransaction>>, uint64_t> DrainRecentlyConflicted();
|
||||||
void SetChainNotifiedSequence(uint64_t recentlyConflictedSequence);
|
void SetChainNotifiedSequence(const CChainParams& chainparams, uint64_t recentlyConflictedSequence);
|
||||||
bool ChainIsFullyNotified();
|
bool ChainIsFullyNotified(const CChainParams& chainparams);
|
||||||
|
|
||||||
#endif // BITCOIN_MAIN_H
|
#endif // BITCOIN_MAIN_H
|
||||||
|
|
|
@ -330,7 +330,7 @@ int printStats(MetricsStats stats, bool isScreen, bool mining)
|
||||||
const Consensus::Params& params = Params().GetConsensus();
|
const Consensus::Params& params = Params().GetConsensus();
|
||||||
auto localsolps = GetLocalSolPS();
|
auto localsolps = GetLocalSolPS();
|
||||||
|
|
||||||
if (IsInitialBlockDownload(Params())) {
|
if (IsInitialBlockDownload(Params().GetConsensus())) {
|
||||||
if (fReindex) {
|
if (fReindex) {
|
||||||
int downloadPercent = nSizeReindexed * 100 / nFullSizeToReindex;
|
int downloadPercent = nSizeReindexed * 100 / nFullSizeToReindex;
|
||||||
std::cout << " " << _("Reindexing blocks") << " | "
|
std::cout << " " << _("Reindexing blocks") << " | "
|
||||||
|
@ -418,7 +418,7 @@ int printMiningStatus(bool mining)
|
||||||
}
|
}
|
||||||
if (fvNodesEmpty) {
|
if (fvNodesEmpty) {
|
||||||
std::cout << _("Mining is paused while waiting for connections.") << std::endl;
|
std::cout << _("Mining is paused while waiting for connections.") << std::endl;
|
||||||
} else if (IsInitialBlockDownload(Params())) {
|
} else if (IsInitialBlockDownload(Params().GetConsensus())) {
|
||||||
std::cout << _("Mining is paused while downloading blocks.") << std::endl;
|
std::cout << _("Mining is paused while downloading blocks.") << std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << _("Mining is paused (a JoinSplit may be in progress).") << std::endl;
|
std::cout << _("Mining is paused (a JoinSplit may be in progress).") << std::endl;
|
||||||
|
|
|
@ -753,7 +753,7 @@ void static BitcoinMiner(const CChainParams& chainparams)
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
fvNodesEmpty = vNodes.empty();
|
fvNodesEmpty = vNodes.empty();
|
||||||
}
|
}
|
||||||
if (!fvNodesEmpty && !IsInitialBlockDownload(chainparams))
|
if (!fvNodesEmpty && !IsInitialBlockDownload(chainparams.GetConsensus()))
|
||||||
break;
|
break;
|
||||||
MilliSleep(1000);
|
MilliSleep(1000);
|
||||||
} while (true);
|
} while (true);
|
||||||
|
|
|
@ -1534,6 +1534,7 @@ bool OpenNetworkConnection(const CAddress& addrConnect, CSemaphoreGrant *grantOu
|
||||||
|
|
||||||
void ThreadMessageHandler()
|
void ThreadMessageHandler()
|
||||||
{
|
{
|
||||||
|
const CChainParams& chainparams = Params();
|
||||||
boost::mutex condition_mutex;
|
boost::mutex condition_mutex;
|
||||||
boost::unique_lock<boost::mutex> lock(condition_mutex);
|
boost::unique_lock<boost::mutex> lock(condition_mutex);
|
||||||
|
|
||||||
|
@ -1568,7 +1569,7 @@ void ThreadMessageHandler()
|
||||||
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv);
|
TRY_LOCK(pnode->cs_vRecvMsg, lockRecv);
|
||||||
if (lockRecv)
|
if (lockRecv)
|
||||||
{
|
{
|
||||||
if (!g_signals.ProcessMessages(pnode))
|
if (!g_signals.ProcessMessages(chainparams, pnode))
|
||||||
pnode->CloseSocketDisconnect();
|
pnode->CloseSocketDisconnect();
|
||||||
|
|
||||||
if (pnode->nSendSize < SendBufferSize())
|
if (pnode->nSendSize < SendBufferSize())
|
||||||
|
@ -1586,7 +1587,7 @@ void ThreadMessageHandler()
|
||||||
{
|
{
|
||||||
TRY_LOCK(pnode->cs_vSend, lockSend);
|
TRY_LOCK(pnode->cs_vSend, lockSend);
|
||||||
if (lockSend)
|
if (lockSend)
|
||||||
g_signals.SendMessages(pnode, pnode == pnodeTrickle || pnode->fWhitelisted);
|
g_signals.SendMessages(chainparams.GetConsensus(), pnode, pnode == pnodeTrickle || pnode->fWhitelisted);
|
||||||
}
|
}
|
||||||
boost::this_thread::interruption_point();
|
boost::this_thread::interruption_point();
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "sync.h"
|
#include "sync.h"
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
#include "utilstrencodings.h"
|
#include "utilstrencodings.h"
|
||||||
|
#include "chainparams.h"
|
||||||
|
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
@ -111,8 +112,8 @@ struct CombinerAll
|
||||||
struct CNodeSignals
|
struct CNodeSignals
|
||||||
{
|
{
|
||||||
boost::signals2::signal<int ()> GetHeight;
|
boost::signals2::signal<int ()> GetHeight;
|
||||||
boost::signals2::signal<bool (CNode*), CombinerAll> ProcessMessages;
|
boost::signals2::signal<bool (const CChainParams&, CNode*), CombinerAll> ProcessMessages;
|
||||||
boost::signals2::signal<bool (CNode*, bool), CombinerAll> SendMessages;
|
boost::signals2::signal<bool (const Consensus::Params&, CNode*, bool), CombinerAll> SendMessages;
|
||||||
boost::signals2::signal<void (NodeId, const CNode*)> InitializeNode;
|
boost::signals2::signal<void (NodeId, const CNode*)> InitializeNode;
|
||||||
boost::signals2::signal<void (NodeId)> FinalizeNode;
|
boost::signals2::signal<void (NodeId)> FinalizeNode;
|
||||||
};
|
};
|
||||||
|
|
|
@ -54,7 +54,7 @@ double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficul
|
||||||
int nShiftAmount = (powLimit >> 24) & 0xff;
|
int nShiftAmount = (powLimit >> 24) & 0xff;
|
||||||
|
|
||||||
double dDiff =
|
double dDiff =
|
||||||
(double)(powLimit & 0x00ffffff) /
|
(double)(powLimit & 0x00ffffff) /
|
||||||
(double)(bits & 0x00ffffff);
|
(double)(bits & 0x00ffffff);
|
||||||
|
|
||||||
while (nShift < nShiftAmount)
|
while (nShift < nShiftAmount)
|
||||||
|
@ -1039,7 +1039,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||||
UniValue obj(UniValue::VOBJ);
|
UniValue obj(UniValue::VOBJ);
|
||||||
obj.pushKV("chain", Params().NetworkIDString());
|
obj.pushKV("chain", Params().NetworkIDString());
|
||||||
obj.pushKV("blocks", (int)chainActive.Height());
|
obj.pushKV("blocks", (int)chainActive.Height());
|
||||||
obj.pushKV("initial_block_download_complete", !IsInitialBlockDownload(Params()));
|
obj.pushKV("initial_block_download_complete", !IsInitialBlockDownload(Params().GetConsensus()));
|
||||||
obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1);
|
obj.pushKV("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1);
|
||||||
obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex());
|
obj.pushKV("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex());
|
||||||
obj.pushKV("difficulty", (double)GetNetworkDifficulty());
|
obj.pushKV("difficulty", (double)GetNetworkDifficulty());
|
||||||
|
@ -1048,7 +1048,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||||
obj.pushKV("pruned", fPruneMode);
|
obj.pushKV("pruned", fPruneMode);
|
||||||
obj.pushKV("size_on_disk", CalculateCurrentUsage());
|
obj.pushKV("size_on_disk", CalculateCurrentUsage());
|
||||||
|
|
||||||
if (IsInitialBlockDownload(Params()))
|
if (IsInitialBlockDownload(Params().GetConsensus()))
|
||||||
obj.pushKV("estimatedheight", EstimateNetHeight(Params().GetConsensus(), (int)chainActive.Height(), chainActive.Tip()->GetMedianTimePast()));
|
obj.pushKV("estimatedheight", EstimateNetHeight(Params().GetConsensus(), (int)chainActive.Height(), chainActive.Tip()->GetMedianTimePast()));
|
||||||
else
|
else
|
||||||
obj.pushKV("estimatedheight", (int)chainActive.Height());
|
obj.pushKV("estimatedheight", (int)chainActive.Height());
|
||||||
|
@ -1063,7 +1063,9 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||||
valuePools.push_back(ValuePoolDesc("sapling", tip->nChainSaplingValue, boost::none));
|
valuePools.push_back(ValuePoolDesc("sapling", tip->nChainSaplingValue, boost::none));
|
||||||
obj.pushKV("valuePools", valuePools);
|
obj.pushKV("valuePools", valuePools);
|
||||||
|
|
||||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
const CChainParams& chainparams = Params();
|
||||||
|
const Consensus::Params& consensusParams = chainparams.GetConsensus();
|
||||||
|
|
||||||
UniValue softforks(UniValue::VARR);
|
UniValue softforks(UniValue::VARR);
|
||||||
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
|
softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
|
||||||
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
|
softforks.push_back(SoftForkDesc("bip66", 3, tip, consensusParams));
|
||||||
|
@ -1091,7 +1093,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Params().NetworkIDString() == "regtest") {
|
if (Params().NetworkIDString() == "regtest") {
|
||||||
obj.pushKV("fullyNotified", ChainIsFullyNotified());
|
obj.pushKV("fullyNotified", ChainIsFullyNotified(chainparams));
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj;
|
||||||
|
@ -1440,7 +1442,7 @@ static const CRPCCommand commands[] =
|
||||||
{ "blockchain", "verifychain", &verifychain, true },
|
{ "blockchain", "verifychain", &verifychain, true },
|
||||||
|
|
||||||
// insightexplorer
|
// insightexplorer
|
||||||
{ "blockchain", "getblockdeltas", &getblockdeltas, false },
|
{ "blockchain", "getblockdeltas", &getblockdeltas, false },
|
||||||
{ "blockchain", "getblockhashes", &getblockhashes, true },
|
{ "blockchain", "getblockhashes", &getblockhashes, true },
|
||||||
|
|
||||||
/* Not shown in help */
|
/* Not shown in help */
|
||||||
|
|
|
@ -551,7 +551,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||||
if (vNodes.empty())
|
if (vNodes.empty())
|
||||||
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Zcash is not connected!");
|
throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Zcash is not connected!");
|
||||||
|
|
||||||
if (IsInitialBlockDownload(Params()))
|
if (IsInitialBlockDownload(Params().GetConsensus()))
|
||||||
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");
|
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks...");
|
||||||
|
|
||||||
static unsigned int nTransactionsUpdatedLast;
|
static unsigned int nTransactionsUpdatedLast;
|
||||||
|
|
|
@ -1109,10 +1109,12 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
|
||||||
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "TX decode failed");
|
||||||
uint256 hashTx = tx.GetHash();
|
uint256 hashTx = tx.GetHash();
|
||||||
|
|
||||||
|
auto chainparams = Params();
|
||||||
|
|
||||||
// DoS mitigation: reject transactions expiring soon
|
// DoS mitigation: reject transactions expiring soon
|
||||||
if (tx.nExpiryHeight > 0) {
|
if (tx.nExpiryHeight > 0) {
|
||||||
int nextBlockHeight = chainActive.Height() + 1;
|
int nextBlockHeight = chainActive.Height() + 1;
|
||||||
if (Params().GetConsensus().NetworkUpgradeActive(nextBlockHeight, Consensus::UPGRADE_OVERWINTER)) {
|
if (chainparams.GetConsensus().NetworkUpgradeActive(nextBlockHeight, Consensus::UPGRADE_OVERWINTER)) {
|
||||||
if (nextBlockHeight + TX_EXPIRING_SOON_THRESHOLD > tx.nExpiryHeight) {
|
if (nextBlockHeight + TX_EXPIRING_SOON_THRESHOLD > tx.nExpiryHeight) {
|
||||||
throw JSONRPCError(RPC_TRANSACTION_REJECTED,
|
throw JSONRPCError(RPC_TRANSACTION_REJECTED,
|
||||||
strprintf("tx-expiring-soon: expiryheight is %d but should be at least %d to avoid transaction expiring soon",
|
strprintf("tx-expiring-soon: expiryheight is %d but should be at least %d to avoid transaction expiring soon",
|
||||||
|
@ -1134,7 +1136,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
|
||||||
// push to local node and sync with wallets
|
// push to local node and sync with wallets
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
bool fMissingInputs;
|
bool fMissingInputs;
|
||||||
if (!AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees)) {
|
if (!AcceptToMemoryPool(chainparams, mempool, state, tx, false, &fMissingInputs, !fOverrideFees)) {
|
||||||
if (state.IsInvalid()) {
|
if (state.IsInvalid()) {
|
||||||
throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason()));
|
throw JSONRPCError(RPC_TRANSACTION_REJECTED, strprintf("%i: %s", state.GetRejectCode(), state.GetRejectReason()));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -48,12 +48,13 @@ BOOST_FIXTURE_TEST_SUITE(DoS_tests, TestingSetup)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(DoS_banning)
|
BOOST_AUTO_TEST_CASE(DoS_banning)
|
||||||
{
|
{
|
||||||
|
const Consensus::Params& params = Params().GetConsensus();
|
||||||
CNode::ClearBanned();
|
CNode::ClearBanned();
|
||||||
CAddress addr1(ip(0xa0b0c001));
|
CAddress addr1(ip(0xa0b0c001));
|
||||||
CNode dummyNode1(INVALID_SOCKET, addr1, "", true);
|
CNode dummyNode1(INVALID_SOCKET, addr1, "", true);
|
||||||
dummyNode1.nVersion = 1;
|
dummyNode1.nVersion = 1;
|
||||||
Misbehaving(dummyNode1.GetId(), 100); // Should get banned
|
Misbehaving(dummyNode1.GetId(), 100); // Should get banned
|
||||||
SendMessages(&dummyNode1, false);
|
SendMessages(params, &dummyNode1, false);
|
||||||
BOOST_CHECK(CNode::IsBanned(addr1));
|
BOOST_CHECK(CNode::IsBanned(addr1));
|
||||||
BOOST_CHECK(!CNode::IsBanned(ip(0xa0b0c001|0x0000ff00))); // Different IP, not banned
|
BOOST_CHECK(!CNode::IsBanned(ip(0xa0b0c001|0x0000ff00))); // Different IP, not banned
|
||||||
|
|
||||||
|
@ -61,35 +62,37 @@ BOOST_AUTO_TEST_CASE(DoS_banning)
|
||||||
CNode dummyNode2(INVALID_SOCKET, addr2, "", true);
|
CNode dummyNode2(INVALID_SOCKET, addr2, "", true);
|
||||||
dummyNode2.nVersion = 1;
|
dummyNode2.nVersion = 1;
|
||||||
Misbehaving(dummyNode2.GetId(), 50);
|
Misbehaving(dummyNode2.GetId(), 50);
|
||||||
SendMessages(&dummyNode2, false);
|
SendMessages(params, &dummyNode2, false);
|
||||||
BOOST_CHECK(!CNode::IsBanned(addr2)); // 2 not banned yet...
|
BOOST_CHECK(!CNode::IsBanned(addr2)); // 2 not banned yet...
|
||||||
BOOST_CHECK(CNode::IsBanned(addr1)); // ... but 1 still should be
|
BOOST_CHECK(CNode::IsBanned(addr1)); // ... but 1 still should be
|
||||||
Misbehaving(dummyNode2.GetId(), 50);
|
Misbehaving(dummyNode2.GetId(), 50);
|
||||||
SendMessages(&dummyNode2, false);
|
SendMessages(params, &dummyNode2, false);
|
||||||
BOOST_CHECK(CNode::IsBanned(addr2));
|
BOOST_CHECK(CNode::IsBanned(addr2));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(DoS_banscore)
|
BOOST_AUTO_TEST_CASE(DoS_banscore)
|
||||||
{
|
{
|
||||||
|
const Consensus::Params& params = Params().GetConsensus();
|
||||||
CNode::ClearBanned();
|
CNode::ClearBanned();
|
||||||
mapArgs["-banscore"] = "111"; // because 11 is my favorite number
|
mapArgs["-banscore"] = "111"; // because 11 is my favorite number
|
||||||
CAddress addr1(ip(0xa0b0c001));
|
CAddress addr1(ip(0xa0b0c001));
|
||||||
CNode dummyNode1(INVALID_SOCKET, addr1, "", true);
|
CNode dummyNode1(INVALID_SOCKET, addr1, "", true);
|
||||||
dummyNode1.nVersion = 1;
|
dummyNode1.nVersion = 1;
|
||||||
Misbehaving(dummyNode1.GetId(), 100);
|
Misbehaving(dummyNode1.GetId(), 100);
|
||||||
SendMessages(&dummyNode1, false);
|
SendMessages(params, &dummyNode1, false);
|
||||||
BOOST_CHECK(!CNode::IsBanned(addr1));
|
BOOST_CHECK(!CNode::IsBanned(addr1));
|
||||||
Misbehaving(dummyNode1.GetId(), 10);
|
Misbehaving(dummyNode1.GetId(), 10);
|
||||||
SendMessages(&dummyNode1, false);
|
SendMessages(params, &dummyNode1, false);
|
||||||
BOOST_CHECK(!CNode::IsBanned(addr1));
|
BOOST_CHECK(!CNode::IsBanned(addr1));
|
||||||
Misbehaving(dummyNode1.GetId(), 1);
|
Misbehaving(dummyNode1.GetId(), 1);
|
||||||
SendMessages(&dummyNode1, false);
|
SendMessages(params, &dummyNode1, false);
|
||||||
BOOST_CHECK(CNode::IsBanned(addr1));
|
BOOST_CHECK(CNode::IsBanned(addr1));
|
||||||
mapArgs.erase("-banscore");
|
mapArgs.erase("-banscore");
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||||
{
|
{
|
||||||
|
const Consensus::Params& params = Params().GetConsensus();
|
||||||
CNode::ClearBanned();
|
CNode::ClearBanned();
|
||||||
int64_t nStartTime = GetTime();
|
int64_t nStartTime = GetTime();
|
||||||
SetMockTime(nStartTime); // Overrides future calls to GetTime()
|
SetMockTime(nStartTime); // Overrides future calls to GetTime()
|
||||||
|
@ -99,7 +102,7 @@ BOOST_AUTO_TEST_CASE(DoS_bantime)
|
||||||
dummyNode.nVersion = 1;
|
dummyNode.nVersion = 1;
|
||||||
|
|
||||||
Misbehaving(dummyNode.GetId(), 100);
|
Misbehaving(dummyNode.GetId(), 100);
|
||||||
SendMessages(&dummyNode, false);
|
SendMessages(params, &dummyNode, false);
|
||||||
BOOST_CHECK(CNode::IsBanned(addr));
|
BOOST_CHECK(CNode::IsBanned(addr));
|
||||||
|
|
||||||
SetMockTime(nStartTime+60*60);
|
SetMockTime(nStartTime+60*60);
|
||||||
|
|
|
@ -409,7 +409,7 @@ BOOST_AUTO_TEST_CASE(AlertDisablesRPC)
|
||||||
mapAlerts.clear();
|
mapAlerts.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool falseFunc(const CChainParams&) { return false; }
|
static bool falseFunc(const Consensus::Params&) { return false; }
|
||||||
|
|
||||||
void PartitionAlertTestImpl(const Consensus::Params& params, int startTime, int expectedTotal, int expectedSlow, int expectedFast)
|
void PartitionAlertTestImpl(const Consensus::Params& params, int startTime, int expectedTotal, int expectedSlow, int expectedFast)
|
||||||
{
|
{
|
||||||
|
@ -435,14 +435,14 @@ void PartitionAlertTestImpl(const Consensus::Params& params, int startTime, int
|
||||||
// Test 1: chain with blocks every nPowTargetSpacing seconds,
|
// Test 1: chain with blocks every nPowTargetSpacing seconds,
|
||||||
// as normal, no worries:
|
// as normal, no worries:
|
||||||
SetMiscWarning("", 0);
|
SetMiscWarning("", 0);
|
||||||
PartitionCheck(falseFunc, csDummy, &indexDummy[799]);
|
PartitionCheck(falseFunc, params, csDummy, &indexDummy[799]);
|
||||||
BOOST_CHECK_EQUAL("", GetMiscWarning().first);
|
BOOST_CHECK_EQUAL("", GetMiscWarning().first);
|
||||||
|
|
||||||
// Test 2: go 3.5 hours without a block, expect a warning:
|
// Test 2: go 3.5 hours without a block, expect a warning:
|
||||||
now += 3*60*60+30*60;
|
now += 3*60*60+30*60;
|
||||||
SetMockTime(now);
|
SetMockTime(now);
|
||||||
SetMiscWarning("", 0);
|
SetMiscWarning("", 0);
|
||||||
PartitionCheck(falseFunc, csDummy, &indexDummy[799]);
|
PartitionCheck(falseFunc, params, csDummy, &indexDummy[799]);
|
||||||
std::string expectedSlowErr = strprintf("WARNING: Check your network connection, %d blocks received in the last 4 hours (%d expected)", expectedSlow, expectedTotal);
|
std::string expectedSlowErr = strprintf("WARNING: Check your network connection, %d blocks received in the last 4 hours (%d expected)", expectedSlow, expectedTotal);
|
||||||
auto warning = GetMiscWarning();
|
auto warning = GetMiscWarning();
|
||||||
// advance 5 seconds so alert time will be in the past
|
// advance 5 seconds so alert time will be in the past
|
||||||
|
@ -456,7 +456,7 @@ void PartitionAlertTestImpl(const Consensus::Params& params, int startTime, int
|
||||||
now += 60*10;
|
now += 60*10;
|
||||||
SetMockTime(now);
|
SetMockTime(now);
|
||||||
SetMiscWarning("", 0);
|
SetMiscWarning("", 0);
|
||||||
PartitionCheck(falseFunc, csDummy, &indexDummy[799]);
|
PartitionCheck(falseFunc, params, csDummy, &indexDummy[799]);
|
||||||
BOOST_CHECK_EQUAL("", GetMiscWarning().first);
|
BOOST_CHECK_EQUAL("", GetMiscWarning().first);
|
||||||
|
|
||||||
// Test 4: get 2.5 times as many blocks as expected:
|
// Test 4: get 2.5 times as many blocks as expected:
|
||||||
|
@ -469,7 +469,7 @@ void PartitionAlertTestImpl(const Consensus::Params& params, int startTime, int
|
||||||
SetMockTime(now);
|
SetMockTime(now);
|
||||||
|
|
||||||
SetMiscWarning("", 0);
|
SetMiscWarning("", 0);
|
||||||
PartitionCheck(falseFunc, csDummy, &indexDummy[799]);
|
PartitionCheck(falseFunc, params, csDummy, &indexDummy[799]);
|
||||||
std::string expectedFastErr = strprintf("WARNING: Abnormally high number of blocks generated, %d blocks received in the last 4 hours (%d expected)", expectedFast, expectedTotal);
|
std::string expectedFastErr = strprintf("WARNING: Abnormally high number of blocks generated, %d blocks received in the last 4 hours (%d expected)", expectedFast, expectedTotal);
|
||||||
warning = GetMiscWarning();
|
warning = GetMiscWarning();
|
||||||
// advance 5 seconds so alert time will be in the past
|
// advance 5 seconds so alert time will be in the past
|
||||||
|
@ -490,7 +490,7 @@ BOOST_AUTO_TEST_CASE(PartitionAlert)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(PartitionAlertBlossomOnly)
|
BOOST_AUTO_TEST_CASE(PartitionAlertBlossomOnly)
|
||||||
{
|
{
|
||||||
PartitionAlertTestImpl(RegtestActivateBlossom(false), 1500000000, 96 * 2, 12 * 2, 240 * 2);
|
PartitionAlertTestImpl(RegtestActivateBlossom(false).GetConsensus(), 1500000000, 96 * 2, 12 * 2, 240 * 2);
|
||||||
RegtestDeactivateBlossom();
|
RegtestDeactivateBlossom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ BOOST_AUTO_TEST_CASE(PartitionAlertBlossomActivates)
|
||||||
// in the slow case, all of the blocks will be blossom blocks
|
// in the slow case, all of the blocks will be blossom blocks
|
||||||
// in the fast case, 96 blocks will be blossom => 96 * 75s * 2/5 = 2880s spent on blossom
|
// in the fast case, 96 blocks will be blossom => 96 * 75s * 2/5 = 2880s spent on blossom
|
||||||
// => (14400 - 2880) / (150 * 2/5) = 11520 / 60 = 192 pre blossom blocks
|
// => (14400 - 2880) / (150 * 2/5) = 11520 / 60 = 192 pre blossom blocks
|
||||||
PartitionAlertTestImpl(RegtestActivateBlossom(false, 799 - 96), 2000000000, 144, 12 * 2, 192 + 96);
|
PartitionAlertTestImpl(RegtestActivateBlossom(false, 799 - 96).GetConsensus(), 2000000000, 144, 12 * 2, 192 + 96);
|
||||||
RegtestDeactivateBlossom();
|
RegtestDeactivateBlossom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ BOOST_AUTO_TEST_CASE(get_next_work)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(get_next_work_blossom)
|
BOOST_AUTO_TEST_CASE(get_next_work_blossom)
|
||||||
{
|
{
|
||||||
const Consensus::Params& params = RegtestActivateBlossom(true);
|
const Consensus::Params& params = RegtestActivateBlossom(true).GetConsensus();
|
||||||
BOOST_CHECK_EQUAL(75, params.PoWTargetSpacing(0));
|
BOOST_CHECK_EQUAL(75, params.PoWTargetSpacing(0));
|
||||||
|
|
||||||
int64_t nLastRetargetTime = 1000000000; // NOTE: Not an actual block time
|
int64_t nLastRetargetTime = 1000000000; // NOTE: Not an actual block time
|
||||||
|
@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_pow_limit)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(get_next_work_pow_limit_blossom)
|
BOOST_AUTO_TEST_CASE(get_next_work_pow_limit_blossom)
|
||||||
{
|
{
|
||||||
const Consensus::Params& params = RegtestActivateBlossom(true);
|
const Consensus::Params& params = RegtestActivateBlossom(true).GetConsensus();
|
||||||
|
|
||||||
int64_t nLastRetargetTime = 1231006505;
|
int64_t nLastRetargetTime = 1231006505;
|
||||||
int64_t nThisTime = 1233061996;
|
int64_t nThisTime = 1233061996;
|
||||||
|
@ -91,7 +91,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual_blossom)
|
BOOST_AUTO_TEST_CASE(get_next_work_lower_limit_actual_blossom)
|
||||||
{
|
{
|
||||||
const Consensus::Params& params = RegtestActivateBlossom(true);
|
const Consensus::Params& params = RegtestActivateBlossom(true).GetConsensus();
|
||||||
|
|
||||||
int64_t nLastRetargetTime = 1000000000; // NOTE: Not an actual block time
|
int64_t nLastRetargetTime = 1000000000; // NOTE: Not an actual block time
|
||||||
int64_t nThisTime = 1000000458;
|
int64_t nThisTime = 1000000458;
|
||||||
|
@ -120,7 +120,7 @@ BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual_blossom)
|
BOOST_AUTO_TEST_CASE(get_next_work_upper_limit_actual_blossom)
|
||||||
{
|
{
|
||||||
const Consensus::Params& params = RegtestActivateBlossom(true);
|
const Consensus::Params& params = RegtestActivateBlossom(true).GetConsensus();
|
||||||
|
|
||||||
int64_t nLastRetargetTime = 1000000000; // NOTE: Not an actual block time
|
int64_t nLastRetargetTime = 1000000000; // NOTE: Not an actual block time
|
||||||
int64_t nThisTime = 1000002908;
|
int64_t nThisTime = 1000002908;
|
||||||
|
@ -160,7 +160,7 @@ BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test)
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test_blossom)
|
BOOST_AUTO_TEST_CASE(GetBlockProofEquivalentTime_test_blossom)
|
||||||
{
|
{
|
||||||
GetBlockProofEquivalentTimeImpl(RegtestActivateBlossom(true));
|
GetBlockProofEquivalentTimeImpl(RegtestActivateBlossom(true).GetConsensus());
|
||||||
RegtestDeactivateBlossom();
|
RegtestDeactivateBlossom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ ToMemPool(CMutableTransaction& tx)
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
return AcceptToMemoryPool(mempool, state, tx, false, NULL, false);
|
return AcceptToMemoryPool(Params(), mempool, state, tx, false, NULL, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_MINING
|
#ifdef ENABLE_MINING
|
||||||
|
|
|
@ -206,7 +206,7 @@ void RegtestDeactivateSapling() {
|
||||||
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT);
|
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::NO_ACTIVATION_HEIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Consensus::Params& RegtestActivateBlossom(bool updatePow, int blossomActivationHeight) {
|
const CChainParams& RegtestActivateBlossom(bool updatePow, int blossomActivationHeight) {
|
||||||
SelectParams(CBaseChainParams::REGTEST);
|
SelectParams(CBaseChainParams::REGTEST);
|
||||||
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
|
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_OVERWINTER, Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
|
||||||
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
|
UpdateNetworkUpgradeParameters(Consensus::UPGRADE_SAPLING, Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
|
||||||
|
@ -214,7 +214,7 @@ const Consensus::Params& RegtestActivateBlossom(bool updatePow, int blossomActiv
|
||||||
if (updatePow) {
|
if (updatePow) {
|
||||||
UpdateRegtestPow(32, 16, uint256S("0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), false);
|
UpdateRegtestPow(32, 16, uint256S("0007ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), false);
|
||||||
}
|
}
|
||||||
return Params().GetConsensus();
|
return Params();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegtestDeactivateBlossom() {
|
void RegtestDeactivateBlossom() {
|
||||||
|
|
|
@ -41,7 +41,7 @@ const Consensus::Params& RegtestActivateSapling();
|
||||||
|
|
||||||
void RegtestDeactivateSapling();
|
void RegtestDeactivateSapling();
|
||||||
|
|
||||||
const Consensus::Params& RegtestActivateBlossom(bool updatePow, int blossomActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
|
const CChainParams& RegtestActivateBlossom(bool updatePow, int blossomActivationHeight = Consensus::NetworkUpgrade::ALWAYS_ACTIVE);
|
||||||
|
|
||||||
void RegtestDeactivateBlossom();
|
void RegtestDeactivateBlossom();
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip)
|
||||||
// Update the notified sequence numbers. We only need this in regtest mode,
|
// Update the notified sequence numbers. We only need this in regtest mode,
|
||||||
// and should not lock on cs or cs_main here otherwise.
|
// and should not lock on cs or cs_main here otherwise.
|
||||||
if (chainParams.NetworkIDString() == "regtest") {
|
if (chainParams.NetworkIDString() == "regtest") {
|
||||||
SetChainNotifiedSequence(recentlyConflicted.second);
|
SetChainNotifiedSequence(chainParams, recentlyConflicted.second);
|
||||||
mempool.SetNotifiedSequence(recentlyAdded.second);
|
mempool.SetNotifiedSequence(recentlyAdded.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,7 @@ void EnsureWalletIsUnlocked()
|
||||||
|
|
||||||
void ThrowIfInitialBlockDownload()
|
void ThrowIfInitialBlockDownload()
|
||||||
{
|
{
|
||||||
if (IsInitialBlockDownload(Params())) {
|
if (IsInitialBlockDownload(Params().GetConsensus())) {
|
||||||
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Error: Sending transactions is not supported during initial block download.");
|
throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Error: Sending transactions is not supported during initial block download.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2159,8 +2159,9 @@ BOOST_AUTO_TEST_CASE(rpc_gettransaction_status_sapling)
|
||||||
BOOST_AUTO_TEST_CASE(rpc_gettransaction_status_blossom)
|
BOOST_AUTO_TEST_CASE(rpc_gettransaction_status_blossom)
|
||||||
{
|
{
|
||||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
auto params = RegtestActivateBlossom(true).GetConsensus();
|
||||||
|
|
||||||
TestWTxStatus(RegtestActivateBlossom(true), DEFAULT_POST_BLOSSOM_TX_EXPIRY_DELTA);
|
TestWTxStatus(params, DEFAULT_POST_BLOSSOM_TX_EXPIRY_DELTA);
|
||||||
|
|
||||||
RegtestDeactivateBlossom();
|
RegtestDeactivateBlossom();
|
||||||
}
|
}
|
||||||
|
|
|
@ -620,7 +620,7 @@ void CWallet::ChainTip(const CBlockIndex *pindex,
|
||||||
ChainTipAdded(pindex, pblock, added->first, added->second);
|
ChainTipAdded(pindex, pblock, added->first, added->second);
|
||||||
// Prevent migration transactions from being created when node is syncing after launch,
|
// Prevent migration transactions from being created when node is syncing after launch,
|
||||||
// and also when node wakes up from suspension/hibernation and incoming blocks are old.
|
// and also when node wakes up from suspension/hibernation and incoming blocks are old.
|
||||||
if (!IsInitialBlockDownload(Params()) &&
|
if (!IsInitialBlockDownload(Params().GetConsensus()) &&
|
||||||
pblock->GetBlockTime() > GetTime() - 3 * 60 * 60)
|
pblock->GetBlockTime() > GetTime() - 3 * 60 * 60)
|
||||||
{
|
{
|
||||||
RunSaplingMigration(pindex->nHeight);
|
RunSaplingMigration(pindex->nHeight);
|
||||||
|
@ -5006,7 +5006,7 @@ int CMerkleTx::GetBlocksToMaturity() const
|
||||||
bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, bool fRejectAbsurdFee)
|
bool CMerkleTx::AcceptToMemoryPool(bool fLimitFree, bool fRejectAbsurdFee)
|
||||||
{
|
{
|
||||||
CValidationState state;
|
CValidationState state;
|
||||||
return ::AcceptToMemoryPool(mempool, state, *this, fLimitFree, NULL, fRejectAbsurdFee);
|
return ::AcceptToMemoryPool(Params(), mempool, state, *this, fLimitFree, NULL, fRejectAbsurdFee);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -67,7 +67,7 @@ void post_wallet_load(){
|
||||||
// Generate coins in the background
|
// Generate coins in the background
|
||||||
if (pwalletMain || !GetArg("-mineraddress", "").empty())
|
if (pwalletMain || !GetArg("-mineraddress", "").empty())
|
||||||
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 1), Params());
|
GenerateBitcoins(GetBoolArg("-gen", false), GetArg("-genproclimit", 1), Params());
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -262,9 +262,9 @@ double benchmark_large_tx(size_t nInputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The two benchmarks, try_decrypt_sprout_notes and try_decrypt_sapling_notes,
|
// The two benchmarks, try_decrypt_sprout_notes and try_decrypt_sapling_notes,
|
||||||
// are checking worst-case scenarios. In both we add n keys to a wallet,
|
// are checking worst-case scenarios. In both we add n keys to a wallet,
|
||||||
// create a transaction using a key not in our original list of n, and then
|
// create a transaction using a key not in our original list of n, and then
|
||||||
// check that the transaction is not associated with any of the keys in our
|
// check that the transaction is not associated with any of the keys in our
|
||||||
// wallet. We call assert(...) to ensure that this is true.
|
// wallet. We call assert(...) to ensure that this is true.
|
||||||
double benchmark_try_decrypt_sprout_notes(size_t nKeys)
|
double benchmark_try_decrypt_sprout_notes(size_t nKeys)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue