From f789229a33b67927ac2baa917c051b06d6124adb Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 2 Feb 2023 21:47:16 +0000 Subject: [PATCH] CreateNewBlock: Leave more space for Orchard shielded coinbase --- src/miner.cpp | 11 ++++++++--- src/miner.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index c01fcc8dd..76e5f1212 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -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 &) { 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& next_cb_mtx) { - resetBlock(); + resetBlock(minerAddress); pblocktemplate.reset(new CBlockTemplate()); diff --git a/src/miner.h b/src/miner.h index 3dd94f381..14d887465 100644 --- a/src/miner.h +++ b/src/miner.h @@ -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);