upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorBitflash <btf01@proton.me>2026-08-02 11:04:00 -0300
committerGitHub <noreply@github.com>2026-08-02 11:04:00 -0300
commitfe04a2045c3080797c6f93bf7cd2e12192b8f68f (patch)
tree4f38cde1114c45bc334d096e90fef94780a66733 /src/main.cpp
parent89f6d045c8e3dacbfbb369a3ac89c0c33de22b4c (diff)
Add consensus block size limit (#111, from #110)
CheckBlock() validated block size against MAX_SIZE, the serializer's generic 32 MB guard rather than a block rule; MAX_BLOCK_SIZE did not exist in this tree at all, because Bitcoin's 1 MB cap arrived in 0.3.x, after the 0.1.0 this fork came from. A miner could produce a 32 MB block and every node would download, verify and store it. Original work by mtg0001 in #110, rebased over #109 with the self-test conflict resolved, plus a comment explaining why the inherited count-against-bytes test stays. Measured before choosing the number: 5709 blocks read from blk0001.dat give a largest block of 34,290 bytes and a median of 216, so 1 MB leaves 29x of headroom and rejects nothing that exists. A node built from this branch then synced genesis to 5706 on the live network with zero size-limit rejections and zero CheckBlock errors -- the same test that caught BIP30 rejecting a real block at height 859.
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 9bb3c24..1b09a1a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1719,7 +1719,7 @@ bool CBlock::CheckBlock() const
1719 // that can be verified before saving an orphan block. 1719 // that can be verified before saving an orphan block.
1720 1720
1721 // Size limits 1721 // Size limits
1722 if (vtx.empty() || vtx.size() > MAX_SIZE || ::GetSerializeSize(*this, SER_DISK) > MAX_SIZE) 1722 if (!CheckSizeLimits())
1723 return error("CheckBlock() : size limits failed"); 1723 return error("CheckBlock() : size limits failed");
1724 1724
1725 // Check timestamp 1725 // Check timestamp