|
|
|
@ -55,9 +55,10 @@ BlockAssembler::Options::Options() {
|
|
|
|
|
nBlockMaxWeight = DEFAULT_BLOCK_MAX_WEIGHT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlockAssembler::BlockAssembler(const CTxMemPool& mempool, const CChainParams& params, const Options& options)
|
|
|
|
|
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool, const CChainParams& params, const Options& options)
|
|
|
|
|
: chainparams(params),
|
|
|
|
|
m_mempool(mempool)
|
|
|
|
|
m_mempool(mempool),
|
|
|
|
|
m_chainstate(chainstate)
|
|
|
|
|
{
|
|
|
|
|
blockMinFeeRate = options.blockMinFeeRate;
|
|
|
|
|
// Limit weight to between 4K and MAX_BLOCK_WEIGHT-4K for sanity:
|
|
|
|
@ -79,8 +80,8 @@ static BlockAssembler::Options DefaultOptions()
|
|
|
|
|
return options;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BlockAssembler::BlockAssembler(const CTxMemPool& mempool, const CChainParams& params)
|
|
|
|
|
: BlockAssembler(mempool, params, DefaultOptions()) {}
|
|
|
|
|
BlockAssembler::BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool, const CChainParams& params)
|
|
|
|
|
: BlockAssembler(chainstate, mempool, params, DefaultOptions()) {}
|
|
|
|
|
|
|
|
|
|
void BlockAssembler::resetBlock()
|
|
|
|
|
{
|
|
|
|
@ -114,7 +115,8 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
|
|
|
|
pblocktemplate->vTxSigOpsCost.push_back(-1); // updated at end
|
|
|
|
|
|
|
|
|
|
LOCK2(cs_main, m_mempool.cs);
|
|
|
|
|
CBlockIndex* pindexPrev = ::ChainActive().Tip();
|
|
|
|
|
assert(std::addressof(*::ChainActive().Tip()) == std::addressof(*m_chainstate.m_chain.Tip()));
|
|
|
|
|
CBlockIndex* pindexPrev = m_chainstate.m_chain.Tip();
|
|
|
|
|
assert(pindexPrev != nullptr);
|
|
|
|
|
nHeight = pindexPrev->nHeight + 1;
|
|
|
|
|
|
|
|
|
@ -173,7 +175,8 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
|
|
|
|
pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]);
|
|
|
|
|
|
|
|
|
|
BlockValidationState state;
|
|
|
|
|
if (!TestBlockValidity(state, chainparams, ::ChainstateActive(), *pblock, pindexPrev, false, false)) {
|
|
|
|
|
assert(std::addressof(::ChainstateActive()) == std::addressof(m_chainstate));
|
|
|
|
|
if (!TestBlockValidity(state, chainparams, m_chainstate, *pblock, pindexPrev, false, false)) {
|
|
|
|
|
throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, state.ToString()));
|
|
|
|
|
}
|
|
|
|
|
int64_t nTime2 = GetTimeMicros();
|
|
|
|
|