Skip to content

Commit

Permalink
consensus: Combine saplingActive conditionals
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom authored and str4d committed Aug 22, 2020
1 parent 50afda0 commit 8175dc5
Showing 1 changed file with 28 additions and 25 deletions.
53 changes: 28 additions & 25 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -861,35 +861,38 @@ bool ContextualCheckTransaction(
error("CheckTransaction(): Sapling version too high"),
REJECT_INVALID, "bad-tx-sapling-version-too-high");
}
} else if (overwinterActive) {
// Reject transactions with valid version but missing overwinter flag
if (tx.nVersion >= OVERWINTER_MIN_TX_VERSION && !tx.fOverwintered) {
return state.DoS(
dosLevelConstricting,
error("ContextualCheckTransaction(): overwinter flag must be set"),
REJECT_INVALID, "tx-overwinter-flag-not-set");
}
} else {
// Rules that apply generally before Sapling. These were
// previously noncontextual checks that became contextual
// after Sapling activation.

// Reject transactions with non-Overwinter version group ID
if (tx.fOverwintered && tx.nVersionGroupId != OVERWINTER_VERSION_GROUP_ID) {
return state.DoS(
dosLevelPotentiallyRelaxing,
error("CheckTransaction(): invalid Overwinter tx version"),
REJECT_INVALID, "bad-overwinter-tx-version-group-id");
}
if (overwinterActive) {
// Reject transactions with valid version but missing overwinter flag
if (tx.nVersion >= OVERWINTER_MIN_TX_VERSION && !tx.fOverwintered) {
return state.DoS(
dosLevelConstricting,
error("ContextualCheckTransaction(): overwinter flag must be set"),
REJECT_INVALID, "tx-overwinter-flag-not-set");
}

// Reject transactions with invalid version
if (tx.fOverwintered && tx.nVersion > OVERWINTER_MAX_TX_VERSION ) {
return state.DoS(
dosLevelPotentiallyRelaxing,
error("CheckTransaction(): overwinter version too high"),
REJECT_INVALID, "bad-tx-overwinter-version-too-high");
// Reject transactions with non-Overwinter version group ID
if (tx.fOverwintered && tx.nVersionGroupId != OVERWINTER_VERSION_GROUP_ID) {
return state.DoS(
dosLevelPotentiallyRelaxing,
error("CheckTransaction(): invalid Overwinter tx version"),
REJECT_INVALID, "bad-overwinter-tx-version-group-id");
}

// Reject transactions with invalid version
if (tx.fOverwintered && tx.nVersion > OVERWINTER_MAX_TX_VERSION ) {
return state.DoS(
dosLevelPotentiallyRelaxing,
error("CheckTransaction(): overwinter version too high"),
REJECT_INVALID, "bad-tx-overwinter-version-too-high");
}
}
}

// Rules that apply before Sapling:
if (!saplingActive) {
// Size limits
// Reject transactions that exceed pre-sapling size limits
BOOST_STATIC_ASSERT(MAX_BLOCK_SIZE > MAX_TX_SIZE_BEFORE_SAPLING); // sanity
if (::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_TX_SIZE_BEFORE_SAPLING)
return state.DoS(
Expand Down

0 comments on commit 8175dc5

Please sign in to comment.