Skip to content

Commit

Permalink
Support Segwit2X rollback protection
Browse files Browse the repository at this point in the history
  • Loading branch information
zander committed Aug 14, 2017
1 parent c6051ce commit b6b2763
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main.cpp
Expand Up @@ -3113,6 +3113,12 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
}
}
}
else if (nHeight == 494784 && Params().NetworkIDString() == CBaseChainParams::MAIN) {
// if this is the SegWit2X initial block, it needs to be larger than 1MB
if (::GetSerializeSize(block, SER_NETWORK, PROTOCOL_VERSION) <= MAX_LEGACY_BLOCK_SIZE)
return state.DoS(100, false, REJECT_INVALID, "bad-blk-length-toosmall", false, "size limits failed");
}

const std::uint32_t blockSizeAcceptLimit = Policy::blockSizeAcceptLimit();
if (block.vtx.size() > blockSizeAcceptLimit || blockSize > blockSizeAcceptLimit) {
const float punishment = (blockSize - blockSizeAcceptLimit) / (float) blockSizeAcceptLimit;
Expand Down

0 comments on commit b6b2763

Please sign in to comment.