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:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 64eb290..4d8031d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4492,6 +4492,17 @@ bool BitcoinMiner(int nThreadId)
4492 // coinbase -- because CheckBlock() weighs the whole serialized 4492 // coinbase -- because CheckBlock() weighs the whole serialized
4493 // block and not just the transactions we chose to add to it. 4493 // block and not just the transactions we chose to add to it.
4494 unsigned int nBlockSize = ::GetSerializeSize(*pblock, SER_DISK); 4494 unsigned int nBlockSize = ::GetSerializeSize(*pblock, SER_DISK);
4495 // Sigops are a budget too, and CheckBlock() enforces one that no
4496 // assembler here counted against. Bytes do not bound validation
4497 // cost: every OP_CHECKSIG is an elliptic-curve verification, so a
4498 // template well inside the size limit can still be refused for
4499 // demanding more work than a block is allowed to. Counted with
4500 // CTransaction::GetSigOpCount, the function CheckBlock() itself
4501 // sums, so the two cannot disagree about what a transaction costs.
4502 //
4503 // Seeded from the coinbase because CheckBlock() sums over all of
4504 // vtx, coinbase included.
4505 unsigned int nBlockSigOps = pblock->vtx[0].GetSigOpCount();
4495 while (fFoundSomething && nBlockSize < MAX_BLOCK_SIZE_GEN) 4506 while (fFoundSomething && nBlockSize < MAX_BLOCK_SIZE_GEN)
4496 { 4507 {
4497 fFoundSomething = false; 4508 fFoundSomething = false;
@@ -4522,8 +4533,9 @@ bool BitcoinMiner(int nThreadId)
4522 // transaction would credit the coinbase for a fee no 4533 // transaction would credit the coinbase for a fee no
4523 // transaction in the block pays, and the block would be 4534 // transaction in the block pays, and the block would be
4524 // rejected for a wholly different reason. 4535 // rejected for a wholly different reason.
4525 unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK); 4536 unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK);
4526 if (!BlockTemplateFits(nBlockSize, nTxSize)) 4537 unsigned int nTxSigOps = tx.GetSigOpCount();
4538 if (!BlockTemplateFits(nBlockSize, nBlockSigOps, nTxSize, nTxSigOps))
4527 continue; 4539 continue;
4528 4540
4529 // Transaction fee requirements, mainly only needed for flood control 4541 // Transaction fee requirements, mainly only needed for flood control
@@ -4537,7 +4549,8 @@ bool BitcoinMiner(int nThreadId)
4537 swap(mapTestPool, mapTestPoolTmp); 4549 swap(mapTestPool, mapTestPoolTmp);
4538 4550
4539 pblock->vtx.push_back(tx); 4551 pblock->vtx.push_back(tx);
4540 nBlockSize += nTxSize; 4552 nBlockSize += nTxSize;
4553 nBlockSigOps += nTxSigOps;
4541 vfAlreadyAdded[n] = true; 4554 vfAlreadyAdded[n] = true;
4542 fFoundSomething = true; 4555 fFoundSomething = true;
4543 } 4556 }