mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-17 02:50:38 +01:00
Merge bitcoin/bitcoin#31490: refactor: inline UndoWriteToDisk and WriteBlockToDisk to reduce serialization calls
223081ece6scripted-diff: rename block and undo functions for consistency (Lőrinc)baaa3b2846refactor,blocks: remove costly asserts and modernize affected logs (Lőrinc)fa39f27a0frefactor,blocks: deduplicate block's serialized size calculations (Lőrinc)dfb2f9d004refactor,blocks: inline `WriteBlockToDisk` (Lőrinc)42bc491465refactor,blocks: inline `UndoWriteToDisk` (Lőrinc)86b85bb11fbench: add SaveBlockBench (Lőrinc)34f9a0157arefactor,bench: rename bench/readblock.cpp to bench/readwriteblock.cpp (Lőrinc) Pull request description: `UndoWriteToDisk` and `WriteBlockToDisk` were delegating a subset of their functionality to single-use methods that didn't optimally capture a meaningful chunk of the algorithm, resulting in calculating things twice (serialized size, header size). This change inlines the awkward methods (asserting that all previous behavior was retained), and in separate commits makes the usages less confusing. Besides making the methods slightly more intuitive, the refactorings reduce duplicate calculations as well. The speed difference is insignificant for now (~0.5% for the new `SaveBlockToDiskBench`), but are a cleanup for follow-ups such as https://github.com/bitcoin/bitcoin/pull/31539 ACKs for top commit: ryanofsky: Code review ACK223081ece6. Since last review, "Save" was renamed to "Write", uint32_t references were dropped, some log statements and comments were improved as suggested, and a lot of tweaks made to commits and commit messages which should make this easier to review. hodlinator: ACK223081ece6TheCharlatan: ACK223081ece6andrewtoth: ACK223081ece6Tree-SHA512: 951bc8ad3504c510988afd95c561e3e259c6212bd14f6536fe56e8eb5bf5c35c32a368bbdb1d5aea1acc473d7e5bd9cdcde02008a148b05af1f955e413062d5c
This commit is contained in:
@@ -1587,7 +1587,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
g_zmq_notification_interface = CZMQNotificationInterface::Create(
|
||||
[&chainman = node.chainman](std::vector<uint8_t>& block, const CBlockIndex& index) {
|
||||
assert(chainman);
|
||||
return chainman->m_blockman.ReadRawBlockFromDisk(block, WITH_LOCK(cs_main, return index.GetBlockPos()));
|
||||
return chainman->m_blockman.ReadRawBlock(block, WITH_LOCK(cs_main, return index.GetBlockPos()));
|
||||
});
|
||||
|
||||
if (g_zmq_notification_interface) {
|
||||
|
||||
Reference in New Issue
Block a user