CreateNewBlock: Leave more space for Orchard shielded coinbase

This commit is contained in:
Jack Grigg 2023-02-02 21:47:16 +00:00
parent 05a1c41aac
commit f789229a33
2 changed files with 9 additions and 4 deletions

View File

@ -345,12 +345,17 @@ BlockAssembler::BlockAssembler(const CChainParams& _chainparams)
nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize);
}
void BlockAssembler::resetBlock()
void BlockAssembler::resetBlock(const MinerAddress& minerAddress)
{
inBlock.clear();
// Reserve space for coinbase tx
nBlockSize = 1000;
// nBlockMaxSize already includes 1000 bytes for transaction structure overhead.
nBlockSize = std::visit(match {
[](const libzcash::OrchardRawAddress&) { return 9000; },
[](const libzcash::SaplingPaymentAddress&) { return 1000; },
[](const boost::shared_ptr<CReserveScript> &) { return 1000; },
}, minerAddress);
nBlockSigOps = 100;
// These counters do not include coinbase tx
@ -370,7 +375,7 @@ CBlockTemplate* BlockAssembler::CreateNewBlock(
const MinerAddress& minerAddress,
const std::optional<CMutableTransaction>& next_cb_mtx)
{
resetBlock();
resetBlock(minerAddress);
pblocktemplate.reset(new CBlockTemplate());

View File

@ -141,7 +141,7 @@ public:
private:
// utility functions
/** Clear the block's state and prepare for assembling a new block */
void resetBlock();
void resetBlock(const MinerAddress& minerAddress);
/** Add a tx to the block */
void AddToBlock(CTxMemPool::txiter iter);