diff options
Diffstat (limited to 'src/main.h')
| -rw-r--r-- | src/main.h | 15 |
1 files changed, 12 insertions, 3 deletions
| @@ -43,15 +43,24 @@ static const unsigned int MAX_BLOCK_SIZE = 1000000; | |||
| 43 | static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE / 2; | 43 | static const unsigned int MAX_BLOCK_SIZE_GEN = MAX_BLOCK_SIZE / 2; |
| 44 | 44 | ||
| 45 | // Room for one more transaction in a template that currently weighs | 45 | // Room for one more transaction in a template that currently weighs |
| 46 | // nBlockSize bytes? | 46 | // nBlockSize bytes and spends nBlockSigOps signature operations? |
| 47 | // | 47 | // |
| 48 | // Asked BEFORE the transaction is appended, never after. A template that has | 48 | // Asked BEFORE the transaction is appended, never after. A template that has |
| 49 | // already overshot is one CheckBlock() rejects, and asking afterwards only | 49 | // already overshot is one CheckBlock() rejects, and asking afterwards only |
| 50 | // measures the waste. Both assemblers call this, so neither can drift into a | 50 | // measures the waste. Both assemblers call this, so neither can drift into a |
| 51 | // different idea of what fits. | 51 | // different idea of what fits. |
| 52 | inline bool BlockTemplateFits(unsigned int nBlockSize, unsigned int nTxSize) | 52 | // |
| 53 | // Size gets a margin (half the cap); sigops do not. There is no cheap way to | ||
| 54 | // spend the sigop budget usefully and no reason to reserve headroom in it, so | ||
| 55 | // assembly holds itself to the same number CheckBlock() enforces -- and to the | ||
| 56 | // same comparison. CheckBlock() fails on `> MAX_BLOCK_SIGOPS`, so a block | ||
| 57 | // sitting exactly on the limit is valid and this has to accept it too. | ||
| 58 | // Assembly and validation disagreeing by one is how the size bug started. | ||
| 59 | inline bool BlockTemplateFits(unsigned int nBlockSize, unsigned int nBlockSigOps, | ||
| 60 | unsigned int nTxSize, unsigned int nTxSigOps) | ||
| 53 | { | 61 | { |
| 54 | return (nBlockSize + nTxSize <= MAX_BLOCK_SIZE_GEN); | 62 | return (nBlockSize + nTxSize <= MAX_BLOCK_SIZE_GEN && |
| 63 | nBlockSigOps + nTxSigOps <= MAX_BLOCK_SIGOPS); | ||
| 55 | } | 64 | } |
| 56 | static const int64 COIN = 100000000; | 65 | static const int64 COIN = 100000000; |
| 57 | // Total Bitflash emission: identical to Bitcoin (21 million). | 66 | // Total Bitflash emission: identical to Bitcoin (21 million). |