Skip to content

Commit 26c475c

Browse files
committed
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.
1 parent 7e73e1d commit 26c475c

File tree

4 files changed

+24
-21
lines changed

4 files changed

+24
-21
lines changed

src/index/base.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <dbwrapper.h>
1010
#include <interfaces/chain.h>
1111
#include <interfaces/types.h>
12-
#include <kernel/chain.h>
1312
#include <kernel/types.h>
1413
#include <logging.h>
1514
#include <node/abort.h>

src/interfaces/chain.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <blockfilter.h>
99
#include <common/settings.h>
10+
#include <kernel/chain.h> // IWYU pragma: export
1011
#include <node/types.h>
1112
#include <primitives/transaction.h>
1213
#include <util/result.h>
@@ -78,22 +79,6 @@ class FoundBlock
7879
mutable bool found = false;
7980
};
8081

81-
//! Block data sent with blockConnected, blockDisconnected notifications.
82-
struct BlockInfo {
83-
const uint256& hash;
84-
const uint256* prev_hash = nullptr;
85-
int height = -1;
86-
int file_number = -1;
87-
unsigned data_pos = 0;
88-
const CBlock* data = nullptr;
89-
const CBlockUndo* undo_data = nullptr;
90-
// The maximum time in the chain up to and including this block.
91-
// A timestamp that can only move forward.
92-
unsigned int chain_time_max{0};
93-
94-
BlockInfo(const uint256& hash LIFETIMEBOUND) : hash(hash) {}
95-
};
96-
9782
//! The action to be taken after updating a settings value.
9883
//! WRITE indicates that the updated value must be written to disk,
9984
//! while SKIP_WRITE indicates that the change will be kept in memory-only

src/kernel/chain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44

55
#include <chain.h>
6-
#include <interfaces/chain.h>
76
#include <kernel/chain.h>
87
#include <kernel/types.h>
8+
#include <kernel/cs_main.h>
99
#include <sync.h>
1010
#include <uint256.h>
1111

src/kernel/chain.h

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,32 @@
55
#ifndef BITCOIN_KERNEL_CHAIN_H
66
#define BITCOIN_KERNEL_CHAIN_H
77

8-
#include<iostream>
8+
#include <attributes.h>
9+
10+
#include <iostream>
911

1012
class CBlock;
1113
class CBlockIndex;
14+
class CBlockUndo;
15+
class uint256;
16+
1217
namespace interfaces {
13-
struct BlockInfo;
14-
} // namespace interfaces
18+
//! Block data sent with blockConnected, blockDisconnected notifications.
19+
struct BlockInfo {
20+
const uint256& hash;
21+
const uint256* prev_hash = nullptr;
22+
int height = -1;
23+
int file_number = -1;
24+
unsigned data_pos = 0;
25+
const CBlock* data = nullptr;
26+
const CBlockUndo* undo_data = nullptr;
27+
// The maximum time in the chain up to and including this block.
28+
// A timestamp that can only move forward.
29+
unsigned int chain_time_max{0};
30+
31+
BlockInfo(const uint256& hash LIFETIMEBOUND) : hash(hash) {}
32+
};
33+
}
1534

1635
namespace kernel {
1736
struct ChainstateRole;

0 commit comments

Comments
 (0)