diff options
author | Ava Chow <github@achow101.com> | 2025-01-07 13:32:56 -0500 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2025-01-07 13:32:56 -0500 |
commit | 32efe850438ef22e2de39e562af557872a402c31 (patch) | |
tree | 6ddb1bce6f76cf2895ed4ad21fb78a29e7833c9f /src/rpc/mining.cpp | |
parent | 6db725662d9edff275abfac6ef3827ebec882f66 (diff) | |
parent | 36314b8da2ee65afd5636fa830d436c5c22bd260 (diff) |
Merge bitcoin/bitcoin#31594: [28.x] 28.1 backports and final changesv28.1
36314b8da2ee65afd5636fa830d436c5c22bd260 doc: Update 28.1 release notes (MarcoFalke)
58910279dcfd989a1712b3dc39a272ff3fbe1136 doc: generate 28.1 manpages (Ava Chow)
6a68ef9bfb39b27d480d4091b60d1c7f9f2d8690 build: bump to 28.1 (Ava Chow)
5b368f88a9fddd0cd48fb014ff9694c555129996 depends: Fix CXXFLAGS on NetBSD (Hennadii Stepanov)
05cd448e3328181d3fe1662bcd7af82cb51833a7 test: generateblocks called by multiple threads (MarcoFalke)
621c634b7fe14fbf151cd222eeaade3505059249 rpc: Extend scope of validation mutex in generateblock (MarcoFalke)
Pull request description:
Backports:
- #31502
- #31563
ACKs for top commit:
glozow:
reACK 36314b8da2ee65afd5636fa830d436c5c22bd260
achow101:
ACK 36314b8da2ee65afd5636fa830d436c5c22bd260
Tree-SHA512: c7a624b4c166f4322011d98d1ca814ae98eaf5fd2481a507cd65a50216f1abbb91f8643508ce81f64f8b10fa2210db1722254c343253f2a950b9c64667735e9b
Diffstat (limited to 'src/rpc/mining.cpp')
-rw-r--r-- | src/rpc/mining.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 3c41e136ec..445fd8c344 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2010 Satoshi Nakamoto -// Copyright (c) 2009-2022 The Bitcoin Core developers +// Copyright (c) 2009-present The Bitcoin Core developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -370,20 +370,21 @@ static RPCHelpMan generateblock() ChainstateManager& chainman = EnsureChainman(node); { - std::unique_ptr<CBlockTemplate> blocktemplate{miner.createNewBlock(coinbase_script, {.use_mempool = false})}; - if (!blocktemplate) { - throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block"); + LOCK(chainman.GetMutex()); + { + std::unique_ptr<CBlockTemplate> blocktemplate{miner.createNewBlock(coinbase_script, {.use_mempool = false})}; + if (!blocktemplate) { + throw JSONRPCError(RPC_INTERNAL_ERROR, "Couldn't create new block"); + } + block = blocktemplate->block; } - block = blocktemplate->block; - } - CHECK_NONFATAL(block.vtx.size() == 1); + CHECK_NONFATAL(block.vtx.size() == 1); - // Add transactions - block.vtx.insert(block.vtx.end(), txs.begin(), txs.end()); - RegenerateCommitments(block, chainman); + // Add transactions + block.vtx.insert(block.vtx.end(), txs.begin(), txs.end()); + RegenerateCommitments(block, chainman); - { BlockValidationState state; if (!miner.testBlockValidity(block, /*check_merkle_root=*/false, state)) { throw JSONRPCError(RPC_VERIFY_ERROR, strprintf("testBlockValidity failed: %s", state.ToString())); |