mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-08 13:49:35 +02:00
Merge bitcoin/bitcoin#24050: validation: Give m_block_index ownership of CBlockIndexs
6c23c41561refactor: Rewrite AddToBlockIndex with try_emplace (Carl Dong)c05cf7aa1estyle: Modernize range-based loops over m_block_index (Carl Dong)c2a1655799style-only: Use using instead of typedef for BlockMap (Carl Dong)dd79dad175refactor: Rewrite InsertBlockIndex with try_emplace (Carl Dong)531dce0347tests: Remove now-unnecessary manual Unload's (Carl Dong)bec86ae326blockstorage: Make m_block_index own CBlockIndex's (Carl Dong) Pull request description: Part of: #24303 Split off from: #22564 ``` Instead of having CBlockIndex's live on the heap, which requires manual memory management, have them be owned by m_block_index. This means that they will live and die with BlockManager. ``` The second commit demonstrates how this makes calls to `Unload()` to satisfy the address sanitizer unnecessary. ACKs for top commit: ajtowns: ACK6c23c41561MarcoFalke: re-ACK6c23c41561🎨 Tree-SHA512: 81b2b5119be27cc0f8a9457b11da60cc60930315d2a5be36be89fe253d32073ffe622348ff153114b9b3212197bddbc791810913a43811b33cc58e7162bd105b
This commit is contained in:
@@ -367,10 +367,10 @@ static int64_t AddTx(ChainstateManager& chainman, CWallet& wallet, uint32_t lock
|
||||
CBlockIndex* block = nullptr;
|
||||
if (blockTime > 0) {
|
||||
LOCK(cs_main);
|
||||
auto inserted = chainman.BlockIndex().emplace(GetRandHash(), new CBlockIndex);
|
||||
auto inserted = chainman.BlockIndex().emplace(std::piecewise_construct, std::make_tuple(GetRandHash()), std::make_tuple());
|
||||
assert(inserted.second);
|
||||
const uint256& hash = inserted.first->first;
|
||||
block = inserted.first->second;
|
||||
block = &inserted.first->second;
|
||||
block->nTime = blockTime;
|
||||
block->phashBlock = &hash;
|
||||
state = TxStateConfirmed{hash, block->nHeight, /*position_in_block=*/0};
|
||||
|
||||
Reference in New Issue
Block a user