kernel: Move BlockInfo to a kernel file

This should avoid having to include interfaces/chain.h from a kernel
module. interfaces/chain.h in turn includes a bunch of non-kernel
headers, that break the desired library topology and might introduce
entanglement regressions.
This commit is contained in:
TheCharlatan
2025-06-01 19:39:12 +02:00
committed by sedited
parent d69a582e72
commit d3a479cb07
5 changed files with 26 additions and 22 deletions

View File

@@ -209,7 +209,7 @@ if [ "${RUN_TIDY}" = "true" ]; then
fi
# TODO: Consider enforcing IWYU across the entire codebase.
FILES_WITH_ENFORCED_IWYU="/src/((crypto|index)/.*\\.cpp|node/blockstorage.cpp|node/utxo_snapshot.cpp|core_read.cpp|signet.cpp)"
FILES_WITH_ENFORCED_IWYU="/src/((crypto|index)/.*\\.cpp|node/blockstorage.cpp|node/utxo_snapshot.cpp|core_read.cpp|signet.cpp|kernel/chain.cpp)"
jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns)))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_errors.json"
jq --arg patterns "$FILES_WITH_ENFORCED_IWYU" 'map(select(.file | test($patterns) | not))' "${BASE_BUILD_DIR}/compile_commands.json" > "${BASE_BUILD_DIR}/compile_commands_iwyu_warnings.json"

View File

@@ -9,7 +9,6 @@
#include <dbwrapper.h>
#include <interfaces/chain.h>
#include <interfaces/types.h>
#include <kernel/chain.h>
#include <kernel/types.h>
#include <logging.h>
#include <node/abort.h>

View File

@@ -7,6 +7,7 @@
#include <blockfilter.h>
#include <common/settings.h>
#include <kernel/chain.h> // IWYU pragma: export
#include <node/types.h>
#include <primitives/transaction.h>
#include <util/result.h>
@@ -78,22 +79,6 @@ public:
mutable bool found = false;
};
//! Block data sent with blockConnected, blockDisconnected notifications.
struct BlockInfo {
const uint256& hash;
const uint256* prev_hash = nullptr;
int height = -1;
int file_number = -1;
unsigned data_pos = 0;
const CBlock* data = nullptr;
const CBlockUndo* undo_data = nullptr;
// The maximum time in the chain up to and including this block.
// A timestamp that can only move forward.
unsigned int chain_time_max{0};
BlockInfo(const uint256& hash LIFETIMEBOUND) : hash(hash) {}
};
//! The action to be taken after updating a settings value.
//! WRITE indicates that the updated value must be written to disk,
//! while SKIP_WRITE indicates that the change will be kept in memory-only

View File

@@ -2,9 +2,10 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chain.h>
#include <interfaces/chain.h>
#include <kernel/chain.h>
#include <chain.h>
#include <kernel/cs_main.h>
#include <kernel/types.h>
#include <sync.h>
#include <uint256.h>

View File

@@ -5,12 +5,31 @@
#ifndef BITCOIN_KERNEL_CHAIN_H
#define BITCOIN_KERNEL_CHAIN_H
#include<iostream>
#include <attributes.h>
#include <iostream>
class CBlock;
class CBlockIndex;
class CBlockUndo;
class uint256;
namespace interfaces {
struct BlockInfo;
//! Block data sent with blockConnected, blockDisconnected notifications.
struct BlockInfo {
const uint256& hash;
const uint256* prev_hash = nullptr;
int height = -1;
int file_number = -1;
unsigned data_pos = 0;
const CBlock* data = nullptr;
const CBlockUndo* undo_data = nullptr;
// The maximum time in the chain up to and including this block.
// A timestamp that can only move forward.
unsigned int chain_time_max{0};
BlockInfo(const uint256& hash LIFETIMEBOUND) : hash(hash) {}
};
} // namespace interfaces
namespace kernel {