| 128 | } |
| 129 | |
| 130 | BlockAssembler::BlockAssembler(const CChainParams& _chainparams) |
| 131 | : chainParams(_chainparams) |
| 132 | { |
| 133 | // Block resource limits |
| 134 | // If neither -blockmaxsize or -blockmaxweight is given, limit to DEFAULT_BLOCK_MAX_* |
| 135 | // If only one is given, only restrict the specified resource. |
| 136 | // If both are given, restrict both. |
| 137 | nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT; |
| 138 | nBlockMaxSize = DEFAULT_BLOCK_MAX_SIZE; |
| 139 | bool fWeightSet = false; |
| 140 | if (IsArgSet("-blockmaxweight")) { |
| 141 | nBlockMaxWeight = GetArg("-blockmaxweight", DEFAULT_BLOCK_MAX_WEIGHT); |
| 142 | nBlockMaxSize = dgpMaxBlockSerSize; |
| 143 | fWeightSet = true; |
| 144 | } |
| 145 | if (IsArgSet("-blockmaxsize")) { |
| 146 | nBlockMaxSize = GetArg("-blockmaxsize", DEFAULT_BLOCK_MAX_SIZE); |
| 147 | if (!fWeightSet) { |
| 148 | nBlockMaxWeight = nBlockMaxSize * WITNESS_SCALE_FACTOR; |
| 149 | } |
| 150 | } |
| 151 | if (IsArgSet("-blockmintxfee")) { |
| 152 | CAmount n = 0; |
| 153 | ParseMoney(GetArg("-blockmintxfee", ""), n); |
| 154 | blockMinFeeRate = CFeeRate(n); |
| 155 | } else { |
| 156 | blockMinFeeRate = CFeeRate(DEFAULT_BLOCK_MIN_TX_FEE); |
| 157 | } |
| 158 | |
| 159 | // Limit weight to between 4K and dgpMaxBlockWeight-4K for sanity: |
| 160 | nBlockMaxWeight = std::max((unsigned int)4000, std::min((unsigned int)(dgpMaxBlockWeight-4000), nBlockMaxWeight)); |
| 161 | // Limit size to between 1K and dgpMaxBlockSerSize-1K for sanity: |
| 162 | nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(dgpMaxBlockSerSize-1000), nBlockMaxSize)); |
| 163 | // Whether we need to account for byte usage (in addition to weight usage) |
| 164 | fNeedSizeAccounting = (nBlockMaxSize < dgpMaxBlockSerSize-1000); |
| 165 | } |
| 166 | |
| 167 | void BlockAssembler::resetBlock() |
| 168 | { |
nothing calls this directly
no test coverage detected