diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cpp | 14 | ||||
| -rw-r--r-- | src/rpc.cpp | 8 |
2 files changed, 20 insertions, 2 deletions
diff --git a/src/main.cpp b/src/main.cpp index 5d0b70a..37a15c6 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
| @@ -4226,7 +4226,19 @@ bool BitcoinMiner(int nThreadId) | |||
| 4226 | vector<char> vfAlreadyAdded(mapTransactions.size()); | 4226 | vector<char> vfAlreadyAdded(mapTransactions.size()); |
| 4227 | bool fFoundSomething = true; | 4227 | bool fFoundSomething = true; |
| 4228 | unsigned int nBlockSize = 0; | 4228 | unsigned int nBlockSize = 0; |
| 4229 | while (fFoundSomething && nBlockSize < MAX_SIZE/2) | 4229 | // Assembly must stop below the consensus cap that CheckBlock() |
| 4230 | // enforces, or we mine a block our own node then rejects. | ||
| 4231 | // | ||
| 4232 | // This used to read MAX_SIZE/2 (16 MB), which was consistent while | ||
| 4233 | // CheckBlock() also tested against MAX_SIZE (32 MB). Adding | ||
| 4234 | // MAX_BLOCK_SIZE inverted it: assembly could fill 16 MB and | ||
| 4235 | // validation would refuse anything over 1 MB, so a full mempool | ||
| 4236 | // meant solving a block and throwing it away -- with this pool at | ||
| 4237 | // ~90% of hashrate, that is the network stalling, not just us. | ||
| 4238 | // | ||
| 4239 | // Half the cap, keeping the original margin: the test runs before | ||
| 4240 | // a transaction is added, so the loop can overshoot by one tx. | ||
| 4241 | while (fFoundSomething && nBlockSize < MAX_BLOCK_SIZE/2) | ||
| 4230 | { | 4242 | { |
| 4231 | fFoundSomething = false; | 4243 | fFoundSomething = false; |
| 4232 | unsigned int n = 0; | 4244 | unsigned int n = 0; |
diff --git a/src/rpc.cpp b/src/rpc.cpp index da22b1d..03d1f44 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp | |||
| @@ -253,7 +253,13 @@ static bool RebuildJob() | |||
| 253 | pool = tmp; | 253 | pool = tmp; |
| 254 | block.vtx.push_back(tx); | 254 | block.vtx.push_back(tx); |
| 255 | sz += ::GetSerializeSize(tx, SER_NETWORK); | 255 | sz += ::GetSerializeSize(tx, SER_NETWORK); |
| 256 | if (sz > MAX_SIZE / 2) break; | 256 | // Must stay under the consensus cap CheckBlock() enforces. |
| 257 | // This is the pool's job builder, so a block over the cap | ||
| 258 | // is not just one wasted solve -- it is every miner on the | ||
| 259 | // pool working a template the network will reject. The | ||
| 260 | // transaction is already pushed above, so this can overshoot | ||
| 261 | // by one; half the cap leaves room for that. | ||
| 262 | if (sz > MAX_BLOCK_SIZE / 2) break; | ||
| 257 | } | 263 | } |
| 258 | } | 264 | } |
| 259 | } | 265 | } |